Skip to content

Commit

Permalink
chore(website): add bundle analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Oct 10, 2019
1 parent 0b2f984 commit fecd3bf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion website/saber-node.js
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -12,5 +20,6 @@ exports.getWebpackConfig = (config, { type }) => {
})
return smp.wrap(config)
}

return config
}

0 comments on commit fecd3bf

Please sign in to comment.