Skip to content

Commit e3558e6

Browse files
committed
Added analyze script to run bundle analyzer
1 parent 2af96cf commit e3558e6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"test": "./node_modules/.bin/mocha tests/helpers/setup.js tests/**/*.spec.js --require @babel/register",
1414
"test:watch": "npm test -- --watch",
1515
"test:coverage": "nyc npm test",
16-
"build": "./node_modules/.bin/webpack --config webpack.config.prod.js -p"
16+
"build": "./node_modules/.bin/webpack --config webpack.config.prod.js -p",
17+
"analyze": "BUNDLE_ANALYZE=true ./node_modules/.bin/webpack --config webpack.config.prod.js -p"
1718
},
1819
"files": [
1920
"dist"
@@ -98,4 +99,4 @@
9899
"react": "^16.3.0",
99100
"react-dom": "^16.3.0"
100101
}
101-
}
102+
}

webpack.config.prod.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const path = require('path');
22
const CleanWebpackPlugin = require('clean-webpack-plugin');
33
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
4-
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
4+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
5+
6+
//const analyze = process.env.BUNDLE_ANALYZE === 'true' ? new BundleAnalyzerPlugin() : {};
7+
58

69
module.exports = {
710
mode: 'production',
@@ -26,7 +29,7 @@ module.exports = {
2629
new UglifyJsPlugin({
2730
comments: false,
2831
}),
29-
// new BundleAnalyzerPlugin(),
32+
process.env.BUNDLE_ANALYZE === 'true' ? new BundleAnalyzerPlugin() : () => { }
3033
],
3134
module: {
3235
rules: [

0 commit comments

Comments
 (0)