From fecd3bf8cb46b296468d11a442daf1b10bf4cbc7 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Thu, 10 Oct 2019 22:24:38 +0800 Subject: [PATCH] chore(website): add bundle analyzer --- website/saber-node.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/website/saber-node.js b/website/saber-node.js index 57b93b78f..29fe174f0 100644 --- a/website/saber-node.js +++ b/website/saber-node.js @@ -1,9 +1,17 @@ const path = require('path') const SpeedMeasurePlugin = require('speed-measure-webpack-plugin') -const { MEASURE_SPEED } = process.env +const { MEASURE_SPEED, NODE_ENV, BUNDLE_ANALYZER_TOKEN } = process.env exports.getWebpackConfig = (config, { type }) => { + if (type === 'client' && NODE_ENV === 'production' && BUNDLE_ANALYZER_TOKEN) { + config.plugins.push( + require('@bundle-analyzer/webpack-plugin')({ + token: BUNDLE_ANALYZER_TOKEN + }) + ) + } + if (MEASURE_SPEED !== undefined) { // This plugin will disable hot reloading const smp = new SpeedMeasurePlugin({ @@ -12,5 +20,6 @@ exports.getWebpackConfig = (config, { type }) => { }) return smp.wrap(config) } + return config }