Nwb: Enabling css-modules for nwb-sass

Created on 29 Jan 2016  路  6Comments  路  Source: insin/nwb

Hey,

I wasn't able to find a way to enable css-modules for .scss files after looking over the various ways to configure plugins. Maybe I missed something?

I tried some variations of:

loaders: {
  scss: {
    query: {
      modules: true
    }
  }
}
docs support

Most helpful comment

In my case it worked with 'vendor-sass-css':

nwb.config.js:

module.exports = {
  type: 'react-app',
  webpack: {
    loaders: {
      'vendor-sass-css': {
        modules: true,
        localIdentName: '[hash:base64:5]'
      }
    }
  }
}

All 6 comments

The loader id for the css-loader used along with sass-loader would be sass-css - changing scss in your example to that should make it work.


This is a bit fiddly, so it should really be documented explicitly in each plugin's README rather than relying on people finding the right doc in the nwb repo.

  • [ ] Document style loading pipeline config in CSS preprocessor plugin READMEs

This uses sass as an example: https://github.com/insin/nwb/blob/master/docs/Plugins.md

Ah, so close. Thank you!

In my case it worked with 'vendor-sass-css':

nwb.config.js:

module.exports = {
  type: 'react-app',
  webpack: {
    loaders: {
      'vendor-sass-css': {
        modules: true,
        localIdentName: '[hash:base64:5]'
      }
    }
  }
}

Is this still up to date? I've tried a few different ids (sass, sass-css, sass-style, etc.) but can't seem to get it to work

This project has since been upgraded to Webpack 2 so make sure you're using the new Webpack 2 configuration format: webpack.loaders has been renamed to webpack.rules. Also, make sure you have nwb-sass installed in your project.

module.exports = {
  webpack: {
    rules: {
      'sass-css': {
        modules: true,
        localIdentName:  '[hash:base64:5]'
      },
    }
  }
}

An example of this has been added to the docs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tbillington picture tbillington  路  6Comments

feelic picture feelic  路  5Comments

AndyOGo picture AndyOGo  路  4Comments

loklaan picture loklaan  路  3Comments

rudfoss picture rudfoss  路  4Comments