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

Parse number for importLoaders in query parameter #1170

Closed
cdoublev opened this issue Aug 21, 2020 · 1 comment · Fixed by #1178
Closed

Parse number for importLoaders in query parameter #1170

cdoublev opened this issue Aug 21, 2020 · 1 comment · Fixed by #1178

Comments

@cdoublev
Copy link

Following your instructions given in this issue...

  • Operating System: Debian Buster
  • Node Version: 14.7.0
  • NPM Version: 6.14.7
  • webpack Version: 4.44.1
  • css-loader Version: 4.2.1

Expected Behavior / Situation

Run webpack with the following configuration, ie. containing an inline - string - definition of css-loader that contains number as value for importLoaders:

module.exports = {
    // ...
    module: { rules: [{
        test: /\.css$/,
        use: ['style-loader', 'css-loader?importLoaders=1', 'postcss-loader'],
    }] },
    // ...

Actual Behavior / Situation

Error thrown:

ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
 - options.importLoaders should be one of these:
   boolean | integer
   -> Enables/Disables or setups number of loaders applied before CSS loader (https://github.com/webpack-contrib/css-loader#importloaders).
   Details:
    * options.importLoaders should be a boolean.
    * options.importLoaders should be a integer.

Modification Proposal

"importLoaders": {

 // ...
         {
           "type": "integer"
+        },
+        {
+          "type": "string"
         }
       ]
     },
 // ...

importLoaders: rawOptions.importLoaders,

     : loaderContext.sourceMap,
-    importLoaders: rawOptions.importLoaders,
+   importLoaders: parseInt(rawOptions.importLoaders),
     esModule:
       typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule,
   };
@alexander-akait
Copy link
Member

css-loader?importLoaders=1 was deprecated in webpack@5 and will not work, anyway I can support is for query options

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

Successfully merging a pull request may close this issue.

2 participants