Reduced size of output bundle

This commit is contained in:
Kai Moseley 2016-09-21 08:00:38 +01:00
parent bb21933588
commit feb91c8122
3 changed files with 26 additions and 41434 deletions

41442
dist/shell-game.bundle.js vendored

File diff suppressed because one or more lines are too long

View File

@ -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",

View File

@ -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(),
]
};
});