首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为pwa应用程序和next/bundle分析器安装next.config.js文件

为pwa应用程序和next/bundle分析器安装next.config.js文件
EN

Stack Overflow用户
提问于 2022-10-01 05:45:57
回答 1查看 172关注 0票数 0

这是我的next.config.js文件,我想使用next/bundle分析器

代码语言:javascript
复制
/** @type {import('next').NextConfig} */

const withPWA = require("next-pwa")({
  dest: "public",
  register: true,
  skipWaiting: true,
  // put other next-pwa options here
});


const nextConfig = withPWA({
  reactStrictMode: true,
  swcMinify: true,
  images: {
    domains: ["*************"],
  },
  // put other next js options here
});

module.exports = nextConfig;

现在,docs说,我需要对next.config.js文件进行一些修改,以包含env。

代码语言:javascript
复制
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({})

我的问题是如何将此代码添加到现有的next.config.js文件中

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-01 06:20:07

此方法返回一个config对象,尝试以下代码:

代码语言:javascript
复制
module.exports = {...withPWA({}) , ...withBundleAnalyzer({})}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73916092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档