-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
support custom css modules suffix #6232
Comments
I don't use CSS modules myself, but I personally like how Vite has opinions on things and force users to do things in one way only. Having a new option to specify what considers a CSS module doesn't feel right, and I'd personally prefer it to be a Vite plugin instead, if you need it. (My 2 cents) |
@sanyuan0704 would you explain why it can't be achieved by a plugin to justify adding it to core? |
I had similar issue with Vite. I think that bundler should be flexible to handle legacy code bases without changes. There is my message' cite from help channel from discord:
|
If you agree that such functionality is needed, I can make a PR |
I disagree. Vite is a modern bundler which makes certain tradeoffs and opinions so that it's fast and standard today. For example, source code is ESM only, CJS needs to be prebundled, not shimming nodejs modules, etc. Configuring a modern bundler to support legacy codebases doesn't sound right. I think the legacy codebase should be modernized instead. IMO new functionality should only be added if there is a real usecase for it, and not for legacy support. FWIW there's already a PR #6404 |
In our case we do not want to use not moduled css. All global things we place in |
In that case, I think the limitation or pattern should be enforced in the source code instead of in the bundler. You can rename all of the CSS modules to |
We can configure the build folder, we can configure the names of the generated classes. But for some reason we can't customize the project structure. It seems to me that this is a little strange. But this is my personal opinion, I'm not a contributor. I will be very grateful if you tell me how to solve my problem using plugins. I can also give some context. We have not one project, but many microfrontends. To build microfrontends, we have our own utility with webpack under the hood. But our build utility is very strict in terms of project structure and does not have access to build configuration files for end developers. And I had an idea to port my builder from wepback to Vite to improve DX. |
I would probably try making a plugin that has:
Not sure if there's any gotchas but might be worth trying to do so. Otherwise I still think it's best if your project can be refactored to use the |
You have an example here https://github.com/userquin/vite-ssg-swiper/blob/main/vite.config.ts#L29 loading swiper on ssg |
duplicate of #2116 and #2981 |
I wrote a plugin based on bluwy's idea to implement it. https://github.com/jsonz1993/vite-plugin-load-css-module |
It still load XX.module.less, and turn out to be 404 eror |
Clear and concise description of the problem
At present, Vite can only treat files with the suffix of .module.css as css modules. However, some files do not have this suffix, but they still need to be processed by css modules.
Suggested solution
Support within vite,not a plugin.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: