From dcedd17f57c2c7a301c122978557cf34d77088ae Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Thu, 5 Nov 2020 01:08:16 +0530 Subject: [PATCH] Add bundle analyzer to webpack behind env variable (#2330) --- src/packages/excalidraw/package.json | 1 + .../excalidraw/webpack.prod.config.js | 8 +- src/packages/utils/README.md | 2 +- src/packages/utils/package-lock.json | 603 +++++++++++++++++- src/packages/utils/package.json | 2 + src/packages/utils/webpack.prod.config.js | 17 +- 6 files changed, 619 insertions(+), 14 deletions(-) diff --git a/src/packages/excalidraw/package.json b/src/packages/excalidraw/package.json index 1ee9167e..1a7876bc 100644 --- a/src/packages/excalidraw/package.json +++ b/src/packages/excalidraw/package.json @@ -63,6 +63,7 @@ "repository": "https://github.com/excalidraw/excalidraw", "scripts": { "build:umd": "cross-env NODE_ENV=production webpack --config webpack.prod.config.js", + "build:umd:withAnalyzer": "cross-env NODE_ENV=production ANALYZER=true webpack --config webpack.prod.config.js", "pack": "npm run build:umd && npm pack" } } diff --git a/src/packages/excalidraw/webpack.prod.config.js b/src/packages/excalidraw/webpack.prod.config.js index d7482e44..b6ad5470 100644 --- a/src/packages/excalidraw/webpack.prod.config.js +++ b/src/packages/excalidraw/webpack.prod.config.js @@ -1,9 +1,8 @@ const path = require("path"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const TerserPlugin = require("terser-webpack-plugin"); -// uncomment to analyze -// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") -// .BundleAnalyzerPlugin; +const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") + .BundleAnalyzerPlugin; module.exports = { mode: "production", @@ -94,8 +93,7 @@ module.exports = { }, plugins: [ new MiniCssExtractPlugin({ filename: "[name].css" }), - // uncomment to analyze - //new BundleAnalyzerPlugin(), + ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []), ], externals: { react: { diff --git a/src/packages/utils/README.md b/src/packages/utils/README.md index 5366f1f7..d1fe9e29 100644 --- a/src/packages/utils/README.md +++ b/src/packages/utils/README.md @@ -30,7 +30,7 @@ import { exportToSvg, exportToBlob } from "@excalidraw/utils"; To use it in a browser directly: ```html - +