insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)
Other
5.57k stars 331 forks source link

Provide a way to add top-level webpack config for loaders #18

Closed insin closed 8 years ago

insin commented 8 years ago

Some webpack loaders have configuration which can't be expressed as a string, so can't use the current loaders means of setting config, e.g. postcss-loader and stylus-loader

insin commented 8 years ago

Adding a way to either add extra things to the top level webpack config or to receive the generated config for final tweaking yourself is the nuclear option - it's so powerful that I don't want to add it until absolutely necessary.

For this one, I'm thinking that loaders in nwb.config.js should be able to define a config object which gets added to the top-level webpack config object with a pre-configured prop per loader (which loader plugin modules can configure for non-built ins which support this).

e.g. hypothetical customisation of a loader provuded by an nwb-stylus plugin:

var nib = require('nib')

module.exports = {
  type: 'react-app',
  loaders: {
    stylus: {
      config: {
        use: [
          nib()
        ]
      }
    }
  }
}