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

Is it possible to add a WebPack plugin in nwb.config.js? #43

Closed stevesouth closed 8 years ago

stevesouth commented 8 years ago

I can't see how at first glance.

To be clear about my underlying requirement I am trying to add a custom resolver as per.

http://stackoverflow.com/questions/28026428/is-it-possible-to-create-custom-resolver-in-webpack

insin commented 8 years ago

it's not possible at the moment because I wasn't sure how to best expose tweaking of the plugins nwb already manages via its different build configs to the user, but adding support for providing extra plugins might not take much effort.

nwb would need to pass its version of webpack to your config so you can use the plugins it ships with, so how does the following look as a speculative nwb.config.js config API?

var MyConventionResolver = {
  // ...
}

module.exports = function(deps) {
  return {
    type: 'react-app',
    plugins: {
      extra: [
        new deps.webpack.ResolverPlugin([MyConventionResolver])
      ]
    }
  }
}
stevesouth commented 8 years ago

Looks fine, although why don't you have it under webpack.

module.exports = function(deps) {
  return {
    type: 'react-app',
      webpack: {
       plugins: [
          new deps.webpack.ResolverPlugin([MyConventionResolver])
         ]
       }
     }
  }
}
insin commented 8 years ago

I was trying to reduce the amount of nesting needed for config when there wasn't as much of it , probably over-influenced by writing the initial documentation with code examples code per config item.

It does need to be made more consistent, along the lines of Karma config, which all lives under a kaema prop.