Add bundle analyzer to webpack behind env variable (#2330)

This commit is contained in:
Aakansha Doshi 2020-11-05 01:08:16 +05:30 committed by GitHub
parent 455badb23e
commit dcedd17f57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 619 additions and 14 deletions

View file

@ -1,21 +1,23 @@
const webpack = require("webpack");
const path = require("path");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
module.exports = {
mode: "production",
entry: { "excalidraw-utils.min": "./index.js" },
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
library: "ExcalidrawUtils",
libraryTarget: "umd",
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
optimization: {
runtimeChunk: false,
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "excalidraw-utils.min.js",
library: "ExcalidrawUtils",
libraryTarget: "umd",
},
entry: "./index.js",
module: {
rules: [
{
@ -36,5 +38,6 @@ module.exports = {
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []),
],
};