-
-
Notifications
You must be signed in to change notification settings - Fork 608
added localByDefault option to allow you to override default behavior… #465
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
Conversation
… when modules is set to true
Codecov Report
@@ Coverage Diff @@
## master #465 +/- ##
==========================================
+ Coverage 98.3% 98.31% +0.01%
==========================================
Files 10 10
Lines 354 357 +3
Branches 79 81 +2
==========================================
+ Hits 348 351 +3
Misses 6 6
Continue to review full report at Codecov.
|
@hulkish https://github.com/webpack-contrib/css-loader#css-modules ? This should be the current behaviour already, can you elaborate please ? 😛 |
@michael-ciniawsky It is default behavior when you are not using css modules ( This feature will allow you to bypass that logic. |
@hulkish And you did an option to override |
@TrySound No, this option will solely override the I also added tests which ensures that there is no impact for this option unless modules is true. |
@hulkish But this is what modules option does, isn't it? I enables local by default. With modules false it's not default but available. |
@TrySound Yes, you are correct - I suppose the confusion is originating from the name of the option itself Perhaps renaming it to |
@TrySound Yep, that should be the case 😉 |
@hulkish But that's |
@hulkish If I missunderstand something here, please give an example how it will look like before/after |
:global is default without options :) |
@michael-ciniawsky wait...but solely setting localIdentName to true doesn't really enable all the css modules features, though? |
localIdentName customizes local output |
I want css modules to only localize class names which I've selectively designated via |
Then it should work without options. |
@hulkish That should work in global mode |
@i guess I'm confused by the notion... So you're saying that I can use css modules without setting Here's the scenario I'm in..:
@michael-ciniawsky @TrySound Is this possible currently? I guess I incorrectly assumed that |
@hulkish Vendors (e.g Bootstrap) will need to stay global and it is better to reference them as static assets via app/components/component1/*.{css, js}index.css .btn {
background-color: red;
} index.js import styles from './style.css'
function render () {
// styles.btn === "BHML95n"
return `<div class="container"><button class=${styles.btn}></button></div>`
} app/components/component2/*.{css, js}index.css .btn {
background-color: green;
} index.js import styles from './index.css'
function render () {
// styles.btn === "KhJZrL85n"
return `<div class="container"><button class=${styles.btn}></button></div>`
} |
@michael-ciniawsky I agree they would be better moved to a CDN - but the reality is that doing the complete refactor in one single motion introduces more risk than we can afford just by the sheer amount of work and regression involved. Also, this line here: https://github.com/webpack-contrib/css-loader/blob/master/lib/processCss.js#L138 leads me to to believe that there's more to it than just simply defining a |
Yep relevant lines are below, but I can't speak for your particular code base and which caveats this may have or not 😛 https://github.com/webpack-contrib/css-loader/blob/master/lib/processCss.js#L138 (Query) I close this PR since it duplicates the |
What kind of change does this PR introduce?
Feature
Did you add tests for your changes?
Yes.
If relevant, did you update the README?
Yes.
Summary
The default behavior when using
modules: true
uses:local
mode by default. This option allows you to override that behavior. This is useful for porting projects which weren't previously using CSS Modules to start using it.Does this PR introduce a breaking change?
No.
Other information
N/A