Skip to content

Commit 8e93c01

Browse files
author
Daniel Karlsson
committed
Add webpack analyzer
1 parent fb7cd2c commit 8e93c01

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,12 @@ Autofix via eslint:
9696
```
9797
npm run eslint:fix
9898
```
99+
100+
### Additional commands and troubleshooting ###
101+
102+
To run webpack analyzer to check your bundle and packagesizes you can append --analyze to a command
103+
```
104+
npm start -- --analyze
105+
npm run build -- --analyze
106+
npm run build:prod -- --analyze
107+
```

package-lock.json

Lines changed: 69 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"storybook-addon-smart-knobs": "^4.1.2",
123123
"style-loader": "^0.23.1",
124124
"webpack": "^4.30.0",
125+
"webpack-bundle-analyzer": "^3.3.2",
125126
"webpack-cli": "^3.3.1",
126127
"webpack-dev-server": "^3.3.1"
127128
},

webpack.client.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const path = require('path');
44
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
55
const CopyWebpackPlugin = require('copy-webpack-plugin');
6+
const BundleAnalyzerPlugin = process.argv.indexOf('--analyze') !== -1 ? require('webpack-bundle-analyzer').BundleAnalyzerPlugin : false;
67

78
const configFile = require('./internals/config')();
89

@@ -99,4 +100,8 @@ const config = {
99100
]
100101
};
101102

103+
if(BundleAnalyzerPlugin) {
104+
config.plugins.push(new BundleAnalyzerPlugin());
105+
}
106+
102107
module.exports = config;

0 commit comments

Comments
 (0)