Skip to content

Options not passed to loader in ExtractTextPlugin #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dpeek opened this issue Feb 27, 2017 · 1 comment
Closed

Options not passed to loader in ExtractTextPlugin #388

dpeek opened this issue Feb 27, 2017 · 1 comment

Comments

@dpeek
Copy link

dpeek commented Feb 27, 2017

This works:

//...
module: {
  rules: [{
    // ...
  },{
    test: /\.scss$/,
    exclude: [/node_modules/],
    use: [{
      loader: 'style-loader'
    },{
      loader: 'css-loader'
    },{
      loader: 'sass-loader',
      options: {
        includePaths: [
          path.resolve('./node_modules/foundation-sites/scss'),
          path.resolve('./src/web/sass')
        ]
      }
    }]
  }]
}
// ...

While this doesn't:

const extractSass = new ExtractTextPlugin({
  filename: '[name].[contenthash:7].css',
  disable: env.dev === true,
  allChunks: true
 })
// ...
module: {
  rules: [{
    // ...
  },{
    test: /\.scss$/,
    exclude: [/node_modules/],
    loader: extractSass.extract({
      loader: [{
        loader: 'css-loader'
      },{
        loader: 'sass-loader',
        options: {
          includePaths: [
            path.resolve('./node_modules/foundation-sites/scss'),
            path.resolve('./src/web/sass')
          ]
        }
      }],
      // use style-loader in development
      fallbackLoader: 'style-loader'
    })
  }]
}
// ...

Seems like loader-utils getOptions is returning null, as the result of normalizeOptions only has the directory of the requested scss file in includePaths:

// ...
const options = normalizeOptions(this, content, webpackImporter(
    resourcePath,
    pify(this.resolve.bind(this)),
    addNormalizedDependency
));
console.log(options.includePaths);
// ...

Prints:

[ '/ws/src/web' ]
[ '/ws/src/web/containers' ]
[ '/ws/src/web/containers' ]

I'll keep digging to try and isolate what is going on.

@dpeek
Copy link
Author

dpeek commented Feb 27, 2017

My bad, had an outdated version of ExtractTextPlugin (beta.4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant