Provide a flag to auto-prefix local css classes when minified#3914
Provide a flag to auto-prefix local css classes when minified#3914chowey wants to merge 2 commits intoevanw:mainfrom
Conversation
19fcc80 to
7c1e87c
Compare
|
@chowey Any reason to limit this to minified classnames? Local classname collission is still an issue without minification if you use common names such as |
|
@ziemkowski If I understand you correctly, your requirement should already work. So long as your CSS files are correctly identified as CSS modules, local classnames (when minification is disabled) should not be an issue. esbuild already renames them. See this example. Taking these two files: .btn {
color: red;
}.btn {
color: blue;
}they successfully bundle into this one file: /* a.module.css */
.a_btn {
color: red;
}
/* b.module.css */
.b_btn {
color: blue;
} |
|
@evanw is there anything needed to make this acceptable? Such as docs? Or is it a no-go? |
|
Thank you for building this. I come around every know and then and really would need that feature as well. Can anything be done to get a decision here? I assume there are tests missing for a new feature to be merged? |
This addresses #3484 by providing an option to prefix css classes when minifying css modules.
I created the
--local-css-prefixcommand line flag, e.g.--local-css-prefix=myapp-. I also exported this through the Javascript API.You can now do e.g.
With the following input files:
index.js
classes.module.css
This produces the following output files:
dist/index.css
dist/index.js