'NextJs next.config.js adding multiple module.exports [duplicate]

My next.config.js like:

module.exports = withBundleAnalyzer({
  swcMinify: true,

Just want to add this withCss(withPurgeCss())

But have no idea how can I add multiple wrappers?



Solution 1:[1]

You can install next-compose-plugins and use multiple plugins with withPlugins

const { withPlaiceholder } = require("@plaiceholder/next");
const withPlugins = require("next-compose-plugins");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true",
});

const nextConfig = {
  ...global config
};

module.exports = withPlugins(
  [[withPlaiceholder], [withBundleAnalyzer], [..moere]],
  nextConfig
);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaung Khant Zaw