From 2ddcce2940885b36dd5f9b2b318e7ed79c122b3e Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Fri, 17 Jun 2016 16:12:26 +0200 Subject: [PATCH] Optimize javascript file size in production --- dashboard/Makefile | 2 +- dashboard/webpack.config.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dashboard/Makefile b/dashboard/Makefile index 3c57ab4..9914801 100644 --- a/dashboard/Makefile +++ b/dashboard/Makefile @@ -12,7 +12,7 @@ assets.go: $(ASSETS) assets/bundle.js $(GO_BINDATA) $(BINDATA_DEBUG) -pkg=dashboard -prefix "assets/" -o assets.go assets/... assets/bundle.js: node_modules/webpack/bin/webpack.js $(JS_FILES) - ./node_modules/webpack/bin/webpack.js + ./node_modules/webpack/bin/webpack.js --production node_modules/webpack/bin/webpack.js: npm install diff --git a/dashboard/webpack.config.js b/dashboard/webpack.config.js index 23642b1..b98fe60 100644 --- a/dashboard/webpack.config.js +++ b/dashboard/webpack.config.js @@ -27,5 +27,16 @@ module.exports = { }, resolve: { extensions: ['', '.js', '.jsx'] - } + }, + plugins: [ + new webpack.HotModuleReplacementPlugin(), + new webpack.NoErrorsPlugin(), + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production'), + } + }), + new webpack.optimize.UglifyJsPlugin() + ] };