-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Set CSS modules mode depending on file type #261
Conversation
@talyuk Nice job! Would this change require an update to the imported version of css-loader? I suspect that a few more comments in the change log requiring any migration would be helpful. Or maybe some file in the https://github.com/shakacode/shakapacker/tree/master/docs directory? or README? |
package/utils/get_style_rule.js
Outdated
importLoaders: 2 | ||
importLoaders: 2, | ||
modules: { | ||
mode: resourcePath => isModuleFile(resourcePath) ? 'local' : 'icss' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why or why not could we use the auto: true
https://github.com/webpack-contrib/css-loader#auto
options: {
modules: {
auto: true,
},
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@talyuk any comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I skimmed through the docs, and it seems that auto: true
is the best choice for this case since users should be familiar with the behavior and it already does what's proposed in this PR (correct me if I'm wrong). @talyuk What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 auto: true
is the sensible choice here
package/utils/get_style_rule.js
Outdated
importLoaders: 2 | ||
importLoaders: 2, | ||
modules: { | ||
mode: resourcePath => isModuleFile(resourcePath) ? 'local' : 'icss' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 auto: true
is the sensible choice here
Use `mode: 'auto'`
Updated to use |
Summary
Set CSS modules mode to
icss
if a style file is not a module,local
otherwise. It allows usingICSS
features such as:import
and:export
without using furtherCSS Module
functionality. ICSS features were applied by default to all files beforecss-loader@v4
, but it's been changed in the next versions. (Please refer tocss-loader
example)