Next.js: How to implement next-css and next-sass simultanously?

Created on 20 Feb 2018  路  2Comments  路  Source: vercel/next.js

I'm using the new next-css and configure webpack at the same time. So my next.config.js looks like this:

const withCSS = require('@zeit/next-css')
module.exports = withCSS({
  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
  }
})

Now I also need to use SASS files.

const withCSS = require('@zeit/next-css')
const withSass = require('@zeit/next-sass')
module.exports = withCSS({
  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
  }
})
module.exports = withSass()

But this seems to be wrong, as I get the error, that no correct loader for @import(url.... at my semantic.min.css is used.

Most helpful comment

Try:

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
  }
}))

All 2 comments

Try:

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
  }
}))

Leaving my test case here (might be another factor or lucky race conditions, but w/e)

  • withTypescript(withCSS(withSass(opts))) works on production mode, fails on dev mode
  • withSass(withTypescript(withCSS(opts))) works on dev mode, fais on production mode
  • Adding the url-loader didnt make a difference.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

renatorib picture renatorib  路  3Comments

ghost picture ghost  路  3Comments

swrdfish picture swrdfish  路  3Comments

rauchg picture rauchg  路  3Comments

havefive picture havefive  路  3Comments