diff --git a/package.json b/package.json index 5967dddf..9d8c3f71 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "style-loader": "^0.21.0", "uglifyjs-webpack-plugin": "^2.0.1", "webpack": "^4.26.1", + "webpack-bundle-analyzer": "3.0.4", "webpack-cli": "^3.1.2" }, "scripts": { @@ -109,7 +110,8 @@ "serve": "npm run live-serve", "test": "jest", "view-cover": "npm run cover -- --report=html && opn ./coverage/index.html", - "package": "npm-run-all clean lint test build build:prod" + "package": "npm-run-all clean lint test build build:prod", + "analyze-bundle": "babel-node ./tools/analyzeBundle.js" }, "jest": { "testURL": "http://localhost", diff --git a/tools/analyzeBundle.js b/tools/analyzeBundle.js new file mode 100644 index 00000000..4b70d247 --- /dev/null +++ b/tools/analyzeBundle.js @@ -0,0 +1,16 @@ +import webpack from 'webpack'; +import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; +import config from '../webpack.prod'; + +config.plugins.push(new BundleAnalyzerPlugin()); +process.env.NODE_ENV = 'production'; + +const compiler = webpack(config); + +compiler.run((error, stats) => { + if (error) { + throw new Error(error); + } + + console.log(stats); +});