cyrilwanner / next-compose-plugins

💡next-compose-plugins provides a cleaner API for enabling and configuring plugins for next.js
MIT License
733 stars 12 forks source link

bundle analyzer works with next-compose-plugins@1.0.3 but not next-compose-plugins@2.2.0 #26

Open saltycrane opened 4 years ago

saltycrane commented 4 years ago

Using @next/bundle-analyzer does not work for me with the latest 2.2.0 version of next-compose-plugins. It does work with version 1.0.3.

I set up a minimal repro repo with 3 branches that test 3 cases:

"WORKS" means that the bundle analyzer files are opened in the browser after running:

npm install
npm run analyze
pradyuman commented 4 years ago

Running into the same issue here.

ScreamZ commented 4 years ago
const path = require("path");
const withPlugins = require("next-compose-plugins");
const withBundleAnalyzer = require("@next/bundle-analyzer");

const plugins = [[withBundleAnalyzer, { enabled: true }]];

const nextConfig = {
  webpack(config) {
    // Import alias, to use with tsconfig.json
    config.resolve.alias["@modules"] = path.join(__dirname, "modules");

    return config;
  },
};

module.exports = withPlugins(plugin, nextConfig);

Example of not working configuration with bundle analyzed :(

rikjacobs1390 commented 4 years ago

I have exactly the same issue! Any news/updates/fixes on this subject?

pentolbakso commented 4 years ago

try this:

const withPlugins = require("next-compose-plugins");
const css = require("@zeit/next-css");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: true,
});

const nextPlugins = [[css], [withBundleAnalyzer({})]];

current setup: "next": "9.3.5", "next-compose-plugins": "^2.2.0", "@next/bundle-analyzer": "^9.3.6"