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

Add support for CSS Modules with explicit filename #2278

Closed
ro-savage opened this issue May 20, 2017 · 1 comment
Closed

Add support for CSS Modules with explicit filename #2278

ro-savage opened this issue May 20, 2017 · 1 comment
Milestone

Comments

@ro-savage
Copy link
Contributor

ro-savage commented May 20, 2017

I suggest adding support for CSS Modules with an explicit filename, allowing those who wish to use CSS Modules to do so without interfering with importing regular stylesheets including from external packages.

What is CSS Modules
CSS Modules will autogenerate a classname with hash to insure scoped classnames. This means that you no longer have to worry about clashing classnames or using BEM or similar naming convention. It does this in the background when CSS is being generated.

To quote CSS Modules: No more conflicts, explicit dependencies, no global scope.

Explicit file name
[name].modules.css

Regex
CSS Module: /\.modules.css$/
Not Module: /[^\.modules]\.css$/

Reasoning
CSS Modules is widely used, has excellent satisfaction (97%) according to StateOfJS. It also allows an easy alternative with IDE support from CSSinJS solutions and wont interfere with regular css.

Opt-in only
The feature would be entirely optional and a user would have to explicitly opt in by using the naming convention and importing the css file into a JS file.

Gotchas
If someone named a stylesheet [something].modules.css without it actually being a CSS Module and imported it, it would be imported as a CSS Module.

Pull Request
PR #2285

Thoughts?

@gaearon
Copy link
Contributor

gaearon commented Jan 17, 2018

Landed into the next branch in #2285.
Thanks for sticking with us!

@gaearon gaearon closed this as completed Jan 17, 2018
@gaearon gaearon modified the milestones: 2.x, 2.0.0 Jan 17, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants