Skip to content

Options not passed to loader in ExtractTextPlugin #388

@dpeek

Description

@dpeek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions