storybookjs / addon-postcss

This Storybook addon can be used to run the PostCSS preprocessor against your stories.
MIT License
20 stars 22 forks source link

[Bug] #43

Open nathanredblur opened 1 year ago

nathanredblur commented 1 year ago

Describe the bug

I get this error

ModuleError: Module Error (from ../node_modules/@storybook/addon-postcss/node_modules/css-loader/dist/cjs.js):
options.mode must be either "global", "local" or "pure" (default "local")

when I set this configuration:

 addons: [
    {
      name: "@storybook/addon-postcss",
      options: {
        cssLoaderOptions: {
          importLoaders: 1,
          modules: {
            mode: (resourcePath) => {
              if (/\.module\.css$/i.test(resourcePath)) return "local";
              return "icss";
            },
          },
        },
        postcssLoaderOptions: {
          implementation: require("postcss"),
        },
      },
    },
  ],

but official documentation for css-loader https://github.com/webpack-contrib/css-loader#modules allows:

        | "local"
        | "global"
        | "pure"
        | "icss"

Steps to reproduce the behavior

run a project that use css.modules with the previous configuration

Expected behavior

no error happen and icss value is accepted.

Environment

Notes

addon-postcss it's using "css-loader": "^3.6.0", when the latest stable version is 6.7.3 https://www.npmjs.com/package/css-loader?activeTab=versions