vercel / next-plugins

Official Next.js plugins
MIT License
2.68k stars 319 forks source link

CSS and SCSS with NextJS (issue while using multiple loaders: next-sass, next-css) #684

Closed lavshah closed 3 years ago

lavshah commented 3 years ago

Hello!

I am trying to convert a CRA to Next.js. Currently I am facing an issue with styles. As per current structure we have modules based SCSS files.

So what I need is:

I have tried a lot of configurations inside next.config.js but that didn't help me.

Here are the package versions I am using:

next: "^9.5.3",
react: "^16.13.1",
@zeit/next-css: "^1.0.1",
@zeit/next-sass: "^1.0.1",
node-sass: "^4.14.1" / sass: "^1.29.0"

PS: I've tried node-sass & sass separately and together but that didn't help as well.

next.config.js

const withSass = require("@zeit/next-sass");
const withCSS = require("@zeit/next-css");
module.exports = withSass(
  withCSS({
    cssModules: true,  
    cssLoaderOptions: {
      url: false,
    },
    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;
    },
  })
);

NOTE:

Is there a way I can get the both working using some configurations? If you need further details for this issue just mention me and I will be sharing the required details ASAP. I am running on a hard deadline or any kind of help will be much appreciated!

Thanks in advance!

@timneutkens

timneutkens commented 3 years ago

Hi, thanks for creating an issue. We currently recommend using https://nextjs.org/docs/basic-features/built-in-css-support as zeit/next-css and zeit/next-sass have been deprecated in favor of the built-in support.