Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's `webpack.LoaderOptionsPlugin` which allows backwards compatibility, generally solves the problem.

One word of warning: LoaderOptionsPlugin _may_ mess with "context", so you should always redefine it in each plugin option object.

For example, using PostCSS without a .postcssrc:

    // postcss hasn't yet started to use options within rule definitons of
    // webpack 2; instead, we use a LoaderOptionsPlugin which provides
    // webpack 1 support of options to postcss.
    // https://github.com/postcss/postcss-loader/issues/92#issuecomment-251439696
    new webpack.LoaderOptionsPlugin({
      options: {
        // See https://github.com/postcss/postcss-loader/issues/99#issuecomment-248878925 and
        // https://github.com/webpack/webpack/issues/3018#issuecomment-248445176
        context: __dirname,
        postcss: [
          require('postcss-mixins'),
          require('postcss-simple-vars'),
          // TODO: Remove and use css variables (http://cssnext.io/features/#custom-properties-var)
          require('postcss-constants')({
            defaults: defaults
          }),
          require('postcss-each'),
          require('postcss-cssnext')({
            browsers: 'last 2 versions',
            features: {
              // https://github.com/robwierzbowski/node-pixrem/issues/40
              rem: false
            },
            import: true,
            compress: false,
            messages: true
          }),
          require('postcss-nested'),
          require('lost')
        ]
      }
    })
You can get around this by using a postcss plugin to read from the common config file (.postcssrc iirc) also, but I depend on requires for postcss-constants so couldn't.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: