From daa99a8c6d0557990ec6035f388c0f3458ac35db Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 17 Feb 2023 01:25:39 -0500 Subject: [PATCH] Change bundle analysis to output files --- webpack.config.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 4c6182c..c831538 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -127,7 +127,20 @@ function getExtensionConfig(target, mode, env) { } if (env.analyzeBundle) { - plugins.push(new BundleAnalyzerPlugin({ analyzerPort: 'auto' })); + const out = path.join(__dirname, 'out'); + if (!fs.existsSync(out)) { + fs.mkdirSync(out); + } + + plugins.push( + new BundleAnalyzerPlugin({ + analyzerMode: 'static', + generateStatsFile: true, + openAnalyzer: false, + reportFilename: path.join(out, `extension-${target}-bundle-report.html`), + statsFilename: path.join(out, 'stats.json'), + }), + ); } return { @@ -351,7 +364,20 @@ function getWebviewsConfig(mode, env) { } if (env.analyzeBundle) { - plugins.push(new BundleAnalyzerPlugin({ analyzerPort: 'auto' })); + const out = path.join(__dirname, 'out'); + if (!fs.existsSync(out)) { + fs.mkdirSync(out); + } + + plugins.push( + new BundleAnalyzerPlugin({ + analyzerMode: 'static', + generateStatsFile: true, + openAnalyzer: false, + reportFilename: path.join(out, 'webview-bundle-report.html'), + statsFilename: path.join(out, 'stats.json'), + }), + ); } return {