Reduced size of output bundle
This commit is contained in:
parent
bb21933588
commit
feb91c8122
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,7 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "webpack-dev-server --progress --content-base dist/",
|
||||
"build": "webpack --progress --prod",
|
||||
"test": "jest"
|
||||
},
|
||||
"author": "Kai Moseley",
|
||||
|
|
|
@ -4,7 +4,18 @@ const path = require('path');
|
|||
const PATH_ESLINT = path.join(__dirname, '.eslintrc.js');
|
||||
const PATH_SRC = path.join(__dirname, 'src');
|
||||
|
||||
module.exports = {
|
||||
const isProd = process.argv.indexOf('--prod') >= 0;
|
||||
const envPlugins = isProd ? [
|
||||
new webpack.optimize.OccurrenceOrderPlugin(true),
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: { warnings: false, unused: true, dead_code: true },
|
||||
output: { comments: false }
|
||||
}),
|
||||
] : [];
|
||||
const envOptions = isProd ? {} : { devtool: 'inline-source-map' };
|
||||
|
||||
module.exports = Object.assign(envOptions, {
|
||||
context: __dirname,
|
||||
entry: {
|
||||
'shell-game': PATH_SRC
|
||||
|
@ -16,7 +27,6 @@ module.exports = {
|
|||
path: path.join(__dirname, 'dist'),
|
||||
filename: '[name].bundle.js',
|
||||
},
|
||||
devtool: 'inline-source-map',
|
||||
eslint: {
|
||||
configFile: PATH_ESLINT,
|
||||
},
|
||||
|
@ -50,6 +60,7 @@ module.exports = {
|
|||
],
|
||||
},
|
||||
plugins: [
|
||||
...envPlugins,
|
||||
function () {
|
||||
this.plugin('done', () =>
|
||||
setTimeout(() => console.log('\nFinished at ' + (new Date).toLocaleTimeString() + '\n'), 10)
|
||||
|
@ -57,4 +68,4 @@ module.exports = {
|
|||
},
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
]
|
||||
};
|
||||
});
|
Loading…
Reference in New Issue