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

Zero-config scss/postcss/css-modules support #11961

Closed
BPScott opened this issue Aug 13, 2020 · 3 comments
Closed

Zero-config scss/postcss/css-modules support #11961

BPScott opened this issue Aug 13, 2020 · 3 comments

Comments

@BPScott
Copy link

BPScott commented Aug 13, 2020

Is your feature request related to a problem? Please describe.

Storybook v6 has made great strides around simplifying initial setup with its zero-config initiative trying to do the right thing by default with automatic configuration, especially around out-the-box config for typescript.

This tracks with common frameworks like CRA and next.js and redwood (ok, that's not quite as pervasive as the other two), however there's one aspect that these frameworks handle that storybook hasn't yet covered: zero configuration scss, postcss and css-modules integration.

Describe the solution you'd like

For Storybook to provide automatic out-the-box configuration for scss files (through sass-loader), postcss processing (through postcss-loader) and css-modules (through the already included css-loader).

Describe alternatives you've considered

preset-scss exists, and there are docs for defining custom webpack config, however these still put the burden of implementation onto storybook users. Storybook has already decided that telling folks "use the typescript preset" is still too much to teach, so does the same ring true for "use the scss preset"?

"If you use framework X, then use the storybook preset for framework X" is a reasonable argument for app that use a framework, however that doesn't address when you're writing a component library decoupled from an app framework.

Are you able to assist bring the feature to reality?
no

Additional context

Existing frameworks tend say "we'll handle the dependency for sass-loader, but your project will need to add a sass or node-sass dependency", so concerns about adding additional dependency bloat are somewhat mitigated as the loaders on their own don't add too much weight.

It might be worth running some kind of poll to see how many folks currently add support for scss/postcss/css-modules through configuring their webpack config / adding preset-scss to help understand how many people would be positively impacted by this change.

@BPScott
Copy link
Author

BPScott commented Aug 13, 2020

Looks like postcss support, including loading from config files is already covered:

loader: require.resolve('postcss-loader'),

css-modules support for .module.css files could be as simple as adding modules: true to css-loader's options per the docs at https://github.com/webpack-contrib/css-loader#modules. auto:true was added in css-loader 3.5.0 and it looks like SB core is currently using ^3.5.3

@shilman
Copy link
Member

shilman commented Nov 9, 2020

@BPScott @tmeasday here's another reason not to build this into Storybook: #12668

@shilman shilman removed this from the 6.2 essentials milestone Apr 1, 2021
@shilman
Copy link
Member

shilman commented Jun 15, 2023

As of 7.0 we've gone the other way and removed postcss completely from the built-in configuration. However, if you're using a framework that supports it, you might get it out of the box. More on 7.0 frameworks architecture: https://storybook.js.org/blog/framework-api/

@shilman shilman closed this as completed Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants