const withBundleAnalyzer = require("@zeit/next-bundle-analyzer");
module.exports = withBundleAnalyzer({
analyzeServer: ["server", "both"].includes(process.env.BUNDLE_ANALYZE),
analyzeBrowser: ["browser", "both"].includes(process.env.BUNDLE_ANALYZE),
bundleAnalyzerConfig: {
server: {
analyzerMode: 'static',
reportFilename: '../../bundles/server.html'
},
browser: {
analyzerMode: 'static',
reportFilename: '../bundles/client.html'
}
}
});
...
"scripts": {
"dev": "nodemon",
"build": "cross-env BUNDLE_ANALYZE=both next build",
"start": "cross-env NODE_ENV=production next start"
},
...
빌드된 파일의 size가 1MB 안넘게 해주자!! => 코드스플리팅을 하던지 등.. (최적화)
tree shaking
gzip