Skip to content

Instantly share code, notes, and snippets.

@qrg
Last active December 6, 2019 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qrg/4407d358a985f4a71c2a9ef6c29cf58c to your computer and use it in GitHub Desktop.
Save qrg/4407d358a985f4a71c2a9ef6c29cf58c to your computer and use it in GitHub Desktop.
// https://github.com/zeit/next.js/blob/42cff0a09c4ae42016500b1797ae4f0bd8438e88/packages/next-bundle-analyzer/index.js
module.exports = ({ enabled = true } = {}) => (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack (config, options) {
if (enabled) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: options.isServer ? '../analyze/server.html' : './analyze/client.html'
})
)
}
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment