Created
April 21, 2021 12:17
-
-
Save marcinczenko/4b692351ec1023633e26140beaeda15e to your computer and use it in GitHub Desktop.
Example next.config.js to show bundle compilation time in development and bundle stats in production
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebpackBar = require('webpackbar') | |
const withPlugins = require('next-compose-plugins') | |
const withBundleAnalyzer = require('@next/bundle-analyzer')({ | |
enabled: process.env.ANALYZE === 'true' | |
}) | |
const withMDX = require('@next/mdx')({ | |
extension: /\.mdx?$/, | |
use: ['babel-loader', '@mdx-js/loader'] | |
}) | |
module.exports = withPlugins([ | |
[withMDX], | |
[withBundleAnalyzer] | |
], { | |
stats: 'detailed', | |
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { | |
// Note: we provide webpack above so you should not `require` it | |
// Perform customizations to webpack config | |
config.plugins.push(new WebpackBar({ | |
name: 'Bundle' | |
})) | |
// Important: return the modified config | |
return config | |
}, | |
pageExtensions: ['js', 'jsx', 'md', 'mdx'] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment