2

I am using react and next js.I added @zeit/next-css and @zeit/next-sass to next.config file.

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

module.exports = withCSS(withSass());

now I want to load files too.I try this but not working and got error:

module.exports = withCSS(withSass({
    webpack (config, options) {
        config.module.rules.push({
            test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
            use: {
                loader: 'url-loader',
                options: {
                    limit: 100000
                }
            }
        });

        return config;
    }
}));
_app.js:7 Uncaught Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development.

I installed next-images too.but I dont know how can I config it with css and sass?

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

module.exports = withCSS(withSass(withImages ()));//error and not working
1
  • I am having the same problem. The nextjs documentation is not clear on how to use multiple plugins with different configurations. Commented Feb 24, 2020 at 7:51

1 Answer 1

3

You can try like this. next-compose-plugins does the trick.

  const withPlugins = require('next-compose-plugins');
  const withCSS = require("@zeit/next-css");
  const withSass = require('@zeit/next-sass');
  const withImages = require('next-images');

  module.exports = withPlugins([
    [
      withCSS(withSass({}))
    ],
    [
      withImages({})
    ],
  ])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.