Put vendor in an own file in production

This commit is contained in:
uwap 2017-11-06 14:20:35 +01:00
parent d32ee5ac36
commit fb60ba496c
3 changed files with 18 additions and 5 deletions

View file

@ -1,4 +1,5 @@
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
@ -15,6 +16,10 @@ const extractCSS = ExtractTextPlugin.extract({
});
module.exports = merge(common, {
entry: {
main: path.resolve(__dirname, 'src/index.jsx'),
vendor: ['react', 'material-ui', 'mqtt', 'ramda']
},
module: {
loaders: [
{ test: /\.css$/, use: extractCSS },
@ -28,6 +33,13 @@ module.exports = merge(common, {
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
})
}),
new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'runtime'
}),
]
});