Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

Commit 0138bfe

Browse files
committed
add webpack:analyze command
1 parent 2400bb2 commit 0138bfe

File tree

4 files changed

+114
-75
lines changed

4 files changed

+114
-75
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ Then open http://localhost:8000 to see your app.
4141

4242
# Acknowledgements
4343

44-
This projects was adapted from https://github.com/jihchi/rescript-react-realworld-example-app by [@jihchi](https://github.com/jihchi).
44+
This project was adapted from https://github.com/jihchi/rescript-react-realworld-example-app by [@jihchi](https://github.com/jihchi).

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
"scripts": {
1313
"webpack": "webpack -w",
1414
"webpack:production": "webpack --mode=production",
15+
"webpack:analyze": "ANALYZE=true webpack --mode=production",
1516
"server": "webpack-dev-server",
1617
"analyze": "webpack --mode=production --profile --json > stats.json && webpack-bundle-analyzer stats.json",
1718
"test": "echo \"Error: no test specified\" && exit 1"
1819
},
1920
"devDependencies": {
2021
"html-webpack-plugin": "^3.2.0",
2122
"webpack": "^4.44.2",
22-
"webpack-bundle-analyzer": "^3.9.0",
23+
"webpack-bundle-analyzer": "^4.5.0",
2324
"webpack-cli": "^3.3.12",
2425
"webpack-dev-server": "^3.11.0"
2526
},

webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const path = require('path');
22
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
34
const outputDir = path.join(__dirname, 'build/');
45

56
const isProd = process.env.NODE_ENV === 'production';
7+
const withAnalyzer = process.env.ANALYZE == "true";
68

79
module.exports = {
810
entry: './_build/default/src/main.bc.js',
@@ -23,7 +25,10 @@ module.exports = {
2325
template: 'src/index.html',
2426
inject: false,
2527
favicon: "./src/favicon.ico"
26-
})
28+
}),
29+
...(withAnalyzer ? [new BundleAnalyzerPlugin({
30+
analyzerMode: "static",
31+
})] : [])
2732
],
2833
devServer: {
2934
compress: true,

0 commit comments

Comments
 (0)