about summary refs log tree commit diff
path: root/webpack.config.js
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-04-03 19:31:29 -0700
committerGitHub <noreply@github.com>2024-04-03 19:31:29 -0700
commitb1bd7ab6e3bd9226383b6eb979857564775435ad (patch)
tree89d06d4e6293a2255237283ff395eb95ae118191 /webpack.config.js
parent9d9c9095eee865551531911a983f06de5fe4bab0 (diff)
downloadvoidsky-b1bd7ab6e3bd9226383b6eb979857564775435ad.tar.zst
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
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js16
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
 }