From b1bd7ab6e3bd9226383b6eb979857564775435ad Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 3 Apr 2024 19:31:29 -0700 Subject: Add webpack analyzer, PR comments for webpack bundle size (#3383) try that again 9 try that again 8 try that again 7 try that again 6 try that again 5 try that again 4 try that again 3 try that again 2 try that again merge base 3 merge base 2 merge base use latest main commit rather than tag webpack diff analyzer use cache v4 use cache again... blegh blegh try cache again cache try again one more adjutment adjust okay again maybe maybe now? maybe now oops again oops add diff comments add open analyzer script add webpack analyzer --- webpack.config.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'webpack.config.js') diff --git a/webpack.config.js b/webpack.config.js index 7515db8e9..f57ba2e36 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,10 @@ const createExpoWebpackConfigAsync = require('@expo/webpack-config') const {withAlias} = require('@expo/webpack-config/addons') const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin') +const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer') + +const GENERATE_STATS = process.env.EXPO_PUBLIC_GENERATE_STATS === '1' +const OPEN_ANALYZER = process.env.EXPO_PUBLIC_OPEN_ANALYZER === '1' const reactNativeWebWebviewConfiguration = { test: /postMock.html$/, @@ -26,5 +30,17 @@ module.exports = async function (env, argv) { if (env.mode === 'development') { config.plugins.push(new ReactRefreshWebpackPlugin()) } + + if (GENERATE_STATS || OPEN_ANALYZER) { + config.plugins.push( + new BundleAnalyzerPlugin({ + openAnalyzer: OPEN_ANALYZER, + generateStatsFile: true, + statsFilename: '../stats.json', + analyzerMode: OPEN_ANALYZER ? 'server' : 'json', + defaultSizes: 'parsed', + }), + ) + } return config } -- cgit 1.4.1