gpt4 book ai didi

reactjs - next.js 包分析器不会创建页面来查看包

转载 作者:行者123 更新时间:2023-12-04 11:35:48 29 4
gpt4 key购买 nike

我试图通过使用 https://www.npmjs.com/package/@next/bundle-analyzer 来减小我网站的包大小
目前,当我运行 npm analyze

"analyze": "cross-env ANALYZE=true next build",
它不输出具有所需可视化效果的 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(),

)
使用此 nextjs-analyze-app-bundle tutorial .
出了什么问题?

最佳答案

看起来已经回答了 on Vercel's issues board .在此处复制他们的解决方案:

These plugins are functions that enhance the configuration object, soyou have to wrap them instead of providing them as arguments:

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,
}));

关于reactjs - next.js 包分析器不会创建页面来查看包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64747820/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com