cyrilwanner / next-compose-plugins

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

why the webpack option of the last plugin will override the one from next config? #28

Closed videni closed 4 years ago

videni commented 4 years ago
const nextConfig = {
  useFileSystemPublicRoutes: false,
  webpack: (config) => {
     console.log(1);  // not output,  this one is not executed
     config.resolve.alias = {
      ...config.resolve.alias,
      'react-jsonschema-form': '@vidyvideni/react-jsonschema-form',
      '@': path.resolve(__dirname, 'src'),
    };
      return config;
   }
  }
module.exports = withPlugins([
  [withTM, {
    transpileModules: [
      '@ant-design/pro-layout',
      'antd',
    ],
   // If I remove this webpack, the above one will execute, why?
    webpack: (config, options) => { 
console.log(2) ;  // output 2, this one is executed.
      config.resolve.alias = {
        ...config.resolve.alias,
        '@ant-design/pro-layout': require.resolve('@ant-design/pro-layout'),
        'antd': require.resolve('antd'),
      };

      return config;
    },
  }]
], nextConfig)
cyrilwanner commented 4 years ago

This is unfortunately a limitation by next. You will have to define everything inside one webpack function.