From f9c3b0dde0c5cd903ac1c1cac330fa78be18a62c Mon Sep 17 00:00:00 2001 From: Riley Hilliard Date: Thu, 21 Feb 2019 05:21:22 -0800 Subject: [PATCH] Adding webpack-build-analyzer to react-digraph, and wiring up the necessary tooling Resolved #106 --- package.json | 4 +++- tools/analyzeBundle.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tools/analyzeBundle.js 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); +});