-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parcel ignores the PostCSS config for one-off ‘.module.css’ stylesheets. #7177
Comments
Seems reasonable to merge the modules config with the |
@devongovett thanks for the pointers; I’d love to contribute! Will open a PR if I can figure it out for myself. |
So I pulled down Parcel and nearly got it set up. But I kept running in to a problem with the |
Version | |
---|---|
Parcel | v2.0.0 |
Node | v14.15.1 and v12.22.7 |
NPM | v7.5.4 and v6.14.15 |
macOS | v11.5 |
Anyways, I've gotta jump off this for the day. Will try to look at this again and get myself up and running this week!
You probably have to install Xcode or the Xcode Command Line Tools
Run |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
🐛 Bug Report
Parcel lets you enable CSS modules on a per-file basis by appending the
.module
suffix to an individual Sass or CSS sheet. This works amazingly well with zero configuration! (I shudder to think of the hundred-line Weback config I'd have to write otherwise… 🤯) That said, I ran in to some weird behavior when I tried to customize thegenerateScopedName
pattern in my.postcssrc
config per the docs.🎛 Configuration
package.json
.postcssrc
🤔 Behavior
Current Behavior
Per @devongovett's comment, Parcel will only take the
generateScopedName
option in to account when CSS modules are enabled globally in the.postcssrc
config: (This is hinted at in the docs, though it's not entirely clear on first read.)Adding that line does “fix” scoped selector generation so it respects the configured pattern. But it also forces all other stylesheets to be imported as CSS modules by default… 😬
Expected Behavior
Since Parcel supports mixing global and scoped stylesheets right out of the box, I'd argue that the current behavior is, as it stands now, actually quite “broken”. If a developer has defined a scoping pattern in their PostCSS configuration file, the reasonable expectation (at least to my mind) would be for Parcel to respect said config anywhere and anytime a scoped stylesheet is imported. Even for a one-off
.module
file. Regardless of whether scoping is or is not enabled globally! 🙃💁 Further Context
I haven't dove in to the source, so I can't offer much in the way of technical solutions or suggestions… As for context, I personally came across this problem because the default scoping pattern's
_
prefix was causing issues with a little BEM utility I've been tinkering on.Environment
v2.0.0
v14.15.1
v7.5.4
v11.5
Footnotes
https://github.com/parcel-bundler/parcel/issues/6094
https://github.com/parcel-bundler/parcel/issues/1930#issuecomment-446177458 ↩
The text was updated successfully, but these errors were encountered: