Skip to content

Commit

Permalink
introduce bundle analyzer plugin in production build (vuejs-templates…
Browse files Browse the repository at this point in the history
  • Loading branch information
myst729 authored and yyx990803 committed Feb 3, 2017
1 parent 6adb694 commit 2e6fe33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report
{{#unit}}

# run unit tests
Expand Down
5 changes: 5 additions & 0 deletions template/build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ if (config.build.productionGzip) {
)
}

if (config.build.bundleAnalyzerReport) {
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}

module.exports = webpackConfig
7 changes: 6 additions & 1 deletion template/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ module.exports = {
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css']
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
dev: {
env: require('./dev.env'),
Expand Down
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.3",
"json-loader": "^0.5.4",
"webpack-bundle-analyzer": "^2.2.1",
{{#unit}}
"cross-env": "^3.1.4",
"karma": "^1.4.1",
Expand Down

0 comments on commit 2e6fe33

Please sign in to comment.