-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Setting options for css-loader in 3.1.1 #1090
Comments
Footer.css isn't a sass file right? |
Ahh my bad, didn't notice that it's a comment |
Yes, so if you are using
|
Thanks for report. I can reproduce this locally, will push a fix 👍 |
Yes, removing parts where But the bigger issue is that I still can't get
Error:
|
Thanks @hundsim Sorry for the trouble. Will fix and make a new release. Anyway, /Users/me/Documents/my-app/config/webpack/environment.js:4
const cssLoader = sassLoader.use.find(loader => loader.loader === 'css-loader')
^
TypeError: Cannot read property 'use' of undefined Seems like you are still using an old version of |
Hm, no I think I'm on the latest, yarn.lock has this:
And btw, as always, it's me that have to thank you for your incredible work 🙏 |
@hundsim Thank you 🙏 So, can you update me what issues are you having currently? The CSS issue you pointed out, it seems like a bug with css loader: Fails: // hello.css
.container {
max-width: 100%;
}
// good one issue
.world {
max-width: 100%;
}
// see more Works: // hello.css
.container {
max-width: 100%;
}
// good one issue
.world {
max-width: 100%;
} Still works: // hello.css
.container {
max-width: 100%;
}
//good one issue
.world {
max-width: 100%;
}
/* see more */ which probably seems correct because for comments in CSS we use |
Made an example here with css modules support: https://github.com/gauravtiwari/webpacker-3.1.1 |
OK, so this error finally vanished when I ran
So with the above applied and removing In the changelog this is mentioned:
I assume this touches on my problem, but I cannot wrap my head around how to configure so that I can work with .css files again (despite the adhering code example) 😓 |
@hundsim Yep, that's true. If you want to use css modules in .css files, please enable css modules there: const cssRule = environment.loaders.get('css')
const cssLoader = cssRule.use.find(loader => loader.loader === 'css-loader')
cssLoader.options = Object.assign(cssLoader.options, {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
}) |
The idea behind separation is that:
So, it's up to you which one you use for global styles and app styles. |
That separation makes so much sense. And your code clarification was of course obvious.. The "only" thing that I'm still battling with is I'm using relative @import at the top of a .css-file like this, mainly to import variables:
|
|
No errors. At a second thought/check, SASS functionality doesn't seem to be applied at all. No nesting, no "Undefined variable:", not possible to apply SASS features in the same file etc. So perhaps I misunderstood the css-loader settings in config/webpack/environment.js. If we set
then we can import styles into the js-file like so but there is no SASS functionality anymore as it was on Webpacker 3.0? And if this assumption above is correct, then I assume that if we want the SASS functionality as before we have to do 2 things:
Right? |
did you resolve this? we use sass functionality like nesting and mixins, but have all files in .css. and use :global to get global scope. we want to upgrade, so if we convert all .css to .scss everything should work as before? |
Yes, I can confirm that it works if you convert all .css files and references 👍 If you have hundreds of css-files like me, then this speeds things up:
And then I did a "find and replace" in my editor for all .css references to those files. |
In Webpacker 3.0.2 I had these settings in config/webpack/environment.js as outlined in the docs:
But having those settings after upgrading Webpacker is causing this error:
So I tried the example outlined in the Changelog:
The error goes away, but I'm not sure those settings are being applied, because now I'm getting an error about CSS comments:
And error message about local/global scope for css modules:
The text was updated successfully, but these errors were encountered: