Home > other >  Setup next.config.js file for a pwa app and next/bundle-analyzer
Setup next.config.js file for a pwa app and next/bundle-analyzer

Time:10-02

This is my next.config.js file and I want to use next/bundle-analyzer

/** @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;

Now the docs says that I need to make some changes in the next.config.js file to include env vars

const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({})

My question is how can I add this code into my existing next.config.js file

CodePudding user response:

This methods return a config object , try this code :

module.exports = {...withPWA({}) , ...withBundleAnalyzer({})}
  • Related