moxystudio/next-intl

How to use multiple plugins with withNextIntl()({ ...nextConfig }) ?

MorganSD opened this issue · 1 comments

it seems withNextIntl only accepts direct configurations, not plugins!

ex: I attempt to wrap current plugins with withNextIntl but it throws errors

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

const withCSS = require('@zeit/next-css');
const withSass = require('@zeit/next-sass');

const nextConfig = {
  // target: 'serverless',
  webpack(config) {
    config.module.rules.push({
      test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
      use: {
        loader: 'url-loader',
        options: {
          limit: 100000,
          name: '[name].[ext]',
        },
      },
    });

    return config;
  },
};

module.exports = withBundleAnalyzer(withSass(withCSS(nextConfig)));

@MorganSD withNextIntl is a factory, so you need to call it like so: withNextIntl()(nextConfig). This is like that so that we can add options later on if we need it, while being able to use compose or next-compose-plugins. See https://github.com/moxystudio/next-with-moxy/blob/7fbd99e92fdf5d10751da62fbd0399ec09a66b08/next.config.js#L74