Mic*_*orn 5 reactjs webpack next.js webpack-bundle-analyzer
我正在尝试使用https://www.npmjs.com/package/@next/bundle-analyzer来减小我网站的包大小
此刻,当我npm analyze与
"analyze": "cross-env ANALYZE=true next build",
Run Code Online (Sandbox Code Playgroud)
它不输出具有所需可视化效果的 html 文件。
这是我的 next.config.js
const withPWA = require('next-pwa')
const runtimeCaching = require('next-pwa/cache')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withPWA({
pwa: {
dest: 'public',
runtimeCaching,
},
poweredByHeader: false,
},
withBundleAnalyzer(),
)
Run Code Online (Sandbox Code Playgroud)
使用这个nextjs-analyze-app-bundle 教程。
出了什么问题?
小智 4
看起来Vercel 的问题板上已经回答了这个问题。在这里复制他们的解决方案:
这些插件是增强配置对象的函数,因此您必须包装它们而不是将它们作为参数提供:
const withPWA = require('next-pwa')
const runtimeCaching = require('next-pwa/cache')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer(withPWA({
pwa: {
dest: 'public',
runtimeCaching,
},
poweredByHeader: false,
}));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |