Closed
Description
Please note that this template is not optional. If you proceed with this form,
please fill out all fields, or your issue may be closed as "invalid."
Please do not delete this template. Please ask questions on StackOverflow or the
webpack Gitter (https://gitter.im/webpack/webpack). General questions, how-to
questions, and support requests will be closed.
Please do remove this header to acknowledge this message.
- Operating System: Mac OS 10.11.6
- Node Version: 8.2.1
- NPM Version: 5.3.0
- webpack Version: 3.6.0
- webpack-dev-server Version: 2.9.0
- This is a bug
- This is a feature request
- This is a modification request
Code
// webpack.config.js
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
/* create array of vendor libs to use in split from bundle */
const VENDOR_LIBS = [
'react',
'react-dom'
]
module.exports = {
entry: {
bundle: './src/app.js', /* bundle.js will contain everything from app.js */
vendor: VENDOR_LIBS /* vendor.js will contain all VENDOR_LIBS */
},
output: {
path: path.resolve(__dirname, 'dist'), /* output all files to /dist directory */
filename: '[name].[chunkhash].js' /* add a hash to each filename for caching and cache busting */
},
devServer: {
contentBase: path.join(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
},
plugins: [
/*
Create an index.html file from the src/index.html file
and add our <script> and <link> tags to it
*/
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
})
]
};
When running webpack-dev-server --open
I get the following:
Using "setup" is deprecated and will be removed in the next major version. Please use the "before" and "after" hooks instead.
If "setup" was working fine for you until now, simply replace it with "before".
This is a very barebones React/Webpack boilerplate: https://github.com/jarodtaylor/react-boilerplates/tree/master/barebones
Metadata
Metadata
Assignees
Labels
No labels