Skip to content

Invalid example of webpack.config.js in README #1094

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
1 of 4 tasks
shirohana opened this issue Jun 18, 2020 · 0 comments · Fixed by #1095
Closed
1 of 4 tasks

Invalid example of webpack.config.js in README #1094

shirohana opened this issue Jun 18, 2020 · 0 comments · Fixed by #1095

Comments

@shirohana
Copy link

shirohana commented Jun 18, 2020

Documentation Is:

  • Missing
  • Needed
  • Confusing
  • Not Sure?

Please Explain in Detail...

I found the webpack config example in README.md about line 1080 contains some abuses that can cause webpack reports an error:

Uncaught:
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.module.rules[0].use[3] has an unknown property 'test'. These properties are valid:
   object { ident?, loader?, options? }

Your Proposal for Changes

README.md#L1080

  **webpack.config.js**

  ```js
  module.exports = {
    module: {
      rules: [
        {
          // For CSS modules
          // For pure CSS - /\.css$/i,
          // For Sass/SCSS - /\.((c|sa|sc)ss)$/i,
          // For Less - /\.((c|le)ss)$/i,
          test: /\.((c|sa|sc)ss)$/i,
          use: [
            'style-loader',
            {
              loader: 'css-loader',
              options: {
                // Run `postcss-loader` on each CSS `@import`, do not forget that `sass-loader` compile non CSS `@import`'s into a single file
                // If you need run `sass-loader` and `postcss-loader` on each CSS `@import` please set it to `2`
                importLoaders: 1,
                // Automatically enable css modules for files satisfying `/\.module\.\w+$/i` RegExp.
                modules: { auto: true },
              },
            },
            {
              loader: 'postcss-loader',
              options: { plugins: () => [postcssPresetEnv({ stage: 0 })] },
            },
            // Can be `less-loader`
            // The `test` property should be `\.less/i`
            {
-             test: /\.s[ac]ss$/i,
+             // This `test` key is invalid in Rule#UseEntry, recommend to
+             // delete this line and comment together with `For CSS modules...` above
+             // test: /\.s[ac]ss$/i,
              loader: 'sass-loader',
            },
          ],
        },
        ...
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.

1 participant