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

Configure files to be processed as css-modules #2116

Closed
gpoitch opened this issue Feb 20, 2021 · 4 comments
Closed

Configure files to be processed as css-modules #2116

gpoitch opened this issue Feb 20, 2021 · 4 comments

Comments

@gpoitch
Copy link

gpoitch commented Feb 20, 2021

Is your feature request related to a problem? Please describe.
The css modules feature currently requires the file to have a .module.css extension. I'd like to be able to just use .css

Describe the solution you'd like

css: {
    modules: {
      include: /\.css$/,
      exclude: /node_modules/
    }
}

Describe alternatives you've considered
Rename all the css files to use the convention. Simple enough, just find it unclean, less portable/tooling-specific, something extra that has to be explained to a team.

@yyx990803
Copy link
Member

Why is it unclean? Assuming all .css to be CSS modules doesn't make it any less tooling-specific, and you lose the ability to differentiate between module vs. non-module CSS.

I don't think this is something we'll support.

@gpoitch
Copy link
Author

gpoitch commented Feb 22, 2021

you lose the ability to differentiate between module vs. non-module CSS.

The include/exclude api differentiates it. Also I would say going "all-in" on modules is more common than mixing modules/non-modules. The exception is node_modules and could have that be the default for exclude.

Why is it unclean?

Just personal preference to have standard file extensions. I see a similar issue and response for people wanting .js extensions with jsx processing. My feedback would be to think about a general include/exclude api ala weback loader tests to help adoption. Anyway, nice project and I enjoyed evaluating it.

@yyx990803
Copy link
Member

The general idea here is: if it's just "preference", avoid adding yet an option for it. Every new option is more surface for documentation and maintenance.

@Summer-andy
Copy link

Summer-andy commented Apr 26, 2021

i have create a plugin to support it ! https://github.com/Summer-andy/vite-plugin-transform-css-modules

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants