diff options
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 16 |
1 files changed, 16 insertions, 0 deletions
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 } |