diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-02-21 00:42:51 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-02-22 01:29:35 +0300 |
commit | 9a11acabb90ca0bd0826c5c21b09f96015337537 (patch) | |
tree | 4fdc6d6de7de30ac0e7de1ee6c37987d6dcd3eba /config/webpack.config.js | |
parent | cac59408a58a8c6d2c3ce4fa5a27161a186b5ed5 (diff) |
add webpack bundle analyzer to production output
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r-- | config/webpack.config.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 15899993874..e754f68553a 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -5,12 +5,14 @@ var path = require('path'); var webpack = require('webpack'); var StatsPlugin = require('stats-webpack-plugin'); var CompressionPlugin = require('compression-webpack-plugin'); +var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; var ROOT_PATH = path.resolve(__dirname, '..'); var IS_PRODUCTION = process.env.NODE_ENV === 'production'; var IS_DEV_SERVER = process.argv[1].indexOf('webpack-dev-server') !== -1; var DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808; var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false'; +var WEBPACK_REPORT = process.env.WEBPACK_REPORT; var config = { context: path.join(ROOT_PATH, 'app/assets/javascripts'), @@ -120,4 +122,16 @@ if (IS_DEV_SERVER) { config.output.publicPath = '//localhost:' + DEV_SERVER_PORT + config.output.publicPath; } +if (WEBPACK_REPORT) { + config.plugins.push( + new BundleAnalyzerPlugin({ + analyzerMode: 'static', + generateStatsFile: true, + openAnalyzer: false, + reportFilename: path.join(ROOT_PATH, 'webpack-report/index.html'), + statsFilename: path.join(ROOT_PATH, 'webpack-report/stats.json'), + }) + ); +} + module.exports = config; |