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

Should `webpack.plugins` nesting in the configuration file go away? #113

Closed insin closed 8 years ago

insin commented 8 years ago

Just realised webpack.plugins is really an implementation detail - it's just a handy way to group certain configuration (define, html etc.) which will be applied to the default set of Webpack plugins managed by nwb in a particular function, but that's not really relevant to the end user.

Should these all be moved up to webpack?

Before:

  webpack: {
    loaders: {
      css: {
        query: {
          modules: true,
          localIdentName: '[hash:base64:5]'
        }
      }
    },
    plugins: {
      define: {
        __GAPI_KEY__: JSON.stringify('YOURAPIKEY')
      },
      html: {
        mountId: 'root',
        title: 'The Cinnamons'
      }
    },
    postcss: {
      plugins: [
        require('precss'),
        require('autoprefixer'),
        require('cssnano')
      ]
    }
  }

After:

  webpack: {
    define: {
      __GAPI_KEY__: JSON.stringify('YOURAPIKEY')
    },
    html: {
      mountId: 'root',
      title: 'The Cinnamons'
    },
    loaders: {
      css: {
        query: {
          modules: true,
          localIdentName: '[hash:base64:5]'
        }
      }
    },
    postcss: {
      plugins: [
        require('precss'),
        require('autoprefixer'),
        require('cssnano')
      ]
    }
  }
insin commented 8 years ago

Other potential simplifications:

  webpack: {
    define: {
      __GAPI_KEY__: JSON.stringify('YOURAPIKEY')
    },
    html: {
      mountId: 'root',
      title: 'The Cinnamons'
    },
    loaders: {
      css: {
        modules: true,
        localIdentName: '[hash:base64:5]'
      }
    },
    postcss: [
      require('precss'),
      require('autoprefixer'),
      require('cssnano')
    ]
  }
insin commented 8 years ago

All implemented in a25ac149b24a59be1ffb8708d423623e31d9812f and aaf7ef7c2ec90ac325f1fde57e88f452272f307a