Skip to content

Commit 0c151f1

Browse files
Merge pull request LucasBassetti#196 from pascalgagneur/analyze-command
Added analyze script command to run bundle analyzer
2 parents 2af96cf + 20a7a9b commit 0c151f1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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;
55

66
module.exports = {
77
mode: 'production',
@@ -26,7 +26,7 @@ module.exports = {
2626
new UglifyJsPlugin({
2727
comments: false,
2828
}),
29-
// new BundleAnalyzerPlugin(),
29+
process.env.BUNDLE_ANALYZE === 'true' ? new BundleAnalyzerPlugin() : () => { }
3030
],
3131
module: {
3232
rules: [

0 commit comments

Comments
 (0)