UNPKG

gatsby-plugin-webpack-bundle-analyser-v2

Version:

Gatsby plugin with the latest version of [webpack-bundle-analyser](https://github.com/webpack-contrib/webpack-bundle-analyzer) to visualize size of output files with an interactive zoomable treemap.

30 lines (29 loc) 653 B
"use strict"; const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); exports.onCreateWebpackConfig = ({ stage, actions }, { disable = false, devMode = false, ...options }) => { if (disable) return; if (stage === 'develop' && devMode || stage === 'build-javascript') { // Prevent server to keep runing in Gatsby Cloud const defaultOptions = process.env.GATSBY_CLOUD ? { analyzerMode: 'static' } : { analyzerMode: 'server', analyzerPort: 3001 }; actions.setWebpackConfig({ plugins: [new BundleAnalyzerPlugin({ ...defaultOptions, ...options })] }); } };