Skip to content

[Bug] Unable to configure @storybook/addon-styling-webpack with css modules and Tailwind #27

@FranRom

Description

@FranRom

Describe the bug

I have the same issue even after running npx @storybook/auto-config styling
Before I had:
{ name: '@storybook/addon-styling', options: { postCss: true } }
And it's actually working well if I currently use it after the migration to Storybook v8.4.7

Then I run manually npx @storybook/auto-config styling and this is the config I got (it seems detects Tailwind but not css module config as I can see in the README)

{
name: '@storybook/addon-styling-webpack',
  options: {
    rules: [
      {
        test: /\.css$/,
        sideEffects: true,
        use: [
          require.resolve('style-loader'),
          {
            loader: require.resolve('css-loader'),
            options: {
              importLoaders: 1
            }
          },
          {
            loader: require.resolve('postcss-loader'),
            options: {
              implementation: require.resolve('postcss')
            }
          }
        ]
      }
    ]
  }
}

The css modules are not loaded.
I try all the configs in the addon doc without luck...

I also added this config but still not working, the custom class is undefined:

    {
      name: '@storybook/addon-styling-webpack',
      options: {
        rules: [
          {
            test: /\.css$/,
            sideEffects: true,
            use: [
              require.resolve('style-loader'),
              {
                loader: 'css-loader',
                options: {
                  modules: {
                    auto: true,
                    localIdentName: '[name]__[local]--[hash:base64:5]'
                  }
                }
              },
              {
                loader: require.resolve('postcss-loader'),
                options: {
                  implementation: require.resolve('postcss')
                }
              }
            ]
          }
        ]
      }
    }

And If I don't add any extra rule css modules are loading well, but I still missed the tailwind css, so any help is very appreciated at this stage.
Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions