Skip to content
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

node-sass-glob-importer - Example Needs Update for webpack 4.x and Node SASS 4.12: "ValidationError: Invalid options object." #211

Open
GuyPaddock opened this issue Mar 30, 2020 · 2 comments

Comments

@GuyPaddock
Copy link

GuyPaddock commented Mar 30, 2020

On webpack 4.20 with Node SASS 4.12, if I use this configuration syntax from the README:

// webpack.config.js
const globImporter = require('node-sass-glob-importer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
 
module.exports = {
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract([
          {
            loader: 'css-loader'
          }, {
            loader: 'sass-loader',
            options: {
              importer: globImporter()
            }
          }
        ])
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin({
      filename: 'style.css'
    })
  ]
}

... I get this error:

ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.

This syntax (moving importer under sassOptions) works:

// webpack.config.js
const globImporter = require('node-sass-glob-importer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
 
module.exports = {
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract([
          {
            loader: 'css-loader'
          }, {
            loader: 'sass-loader',
            options: {
              sassOptions: {
                importer: globImporter()
              }
            }
          }
        ])
      }
    ]
  },
  plugins: [
    new ExtractTextPlugin({
      filename: 'style.css'
    })
  ]
}
@maslade
Copy link

maslade commented Dec 14, 2020

Hey @GuyPaddock , small world :) I'm running into the same problem and curious if you ever found a solution or alternative. I'm supporting vendor SASS so rewriting the globs out isn't an option for me.

@maslade
Copy link

maslade commented Dec 15, 2020

Looks like this passes option validation, but in my case still reporting "File to import not found or unreadable" when it reaches a glob import.

options: {
  sassOptions: {
    importer: globImporter(),
  }
}

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

2 participants