From 9206ae42a9e4e734d259de78343dba9ebcd22ef3 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Thu, 30 Mar 2023 18:36:30 -0500 Subject: [PATCH] [Dev] Statoscope: Only build reference.json in staging --- webpack.config.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 7194cc899..f2e19ac6a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -141,14 +141,14 @@ module.exports = (_env, { mode = 'production' }) => { }, plugins: [ - { + ...(APP_ENV === 'staging' ? { apply: (compiler) => { compiler.hooks.compile.tap('Before Compilation', async () => { const stats = await fetch(STATOSCOPE_REFERENCE_URL).then((res) => res.text()); fs.writeFileSync(path.resolve('./public/reference.json'), stats); }); }, - }, + } : []), // Clearing of the unused files for code highlight for smaller chunk count new ContextReplacementPlugin( /highlight\.js[\\/]lib[\\/]languages/, @@ -200,10 +200,12 @@ module.exports = (_env, { mode = 'production' }) => { }, saveReportTo: path.resolve('./public/statoscope-report.html'), saveStatsTo: path.resolve('./public/build-stats.json'), - additionalStats: ['./public/reference.json'], normalizeStats: true, open: 'file', extensions: [new WebpackContextExtension()], + ...(APP_ENV === 'staging' && { + additionalStats: ['./public/reference.json'], + }), }), ],