-
Notifications
You must be signed in to change notification settings - Fork 116
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
Play better with postcss-modules #214
Comments
If postcss-import is ran first, composes should just be applied after so not sure neither what is the issue since you are not using standard syntax. |
@MoOx tks for the reply. What do u mean by not standard syntax 😢 ? |
|
Yup its a CSS Modules concept, thus the postcss-modules plugin :(
|
Related: #227. In the future we should probably add an option to turn off forcing |
@RyanZim - did the option to turn off top-level |
@leebenson Actually, I don't think adding such an option is possible; since postcss-import supports media query imports, all imports have to be at the top. Closing since I wasn't aware of this limitation when I wrote the above comment. |
Ah, thanks @RyanZim, that makes sense. I think a few devs are getting hung-up on how to do 'global' imports of third-party scripts, inside a :global {
@import 'someExternalStyle.css';
} Since In my own starter kit, I have a separate config for |
@leebenson |
Thanks @michael-ciniawsky. Your advice is actually exactly how I have it set-up currently, I was just curious whether it was possible to mimic the behaviour within a |
Maybe possible 😛 (when using CSSModules with gulp, grunt), but imho should be consider |
|
The primary benefit I see with being able to define imports inside a Yes, it doesn't take into consideration duplicates, but it does enable true encapsulation of styles to the specific component that needs those third party styles. Examples include Its easy to say "don't do globals at all" but the reality is that we still need to be able to do globals if we want to consume web components authored by other developers. Personally I feel like putting my global imports directly in my document (as opposed to importing them in situ at the component level) defeats the purpose of modularizing CSS to begin with. |
@eriklharper - just to clarify on this thread, the way I was able to 'fix' it in my case was to make globals the work of a separate loader, triggered by the extension This avoids having to rely on Instead, by making .global.css use Then your 'plain' .css files can continue to spit out localised versions, under a separate loader that uses So, using |
I'm a little confused as to the resolution here. Will one ever be able to I get the desire to adhere to the spec, but this is a CSS processing toolchain, most |
If I stack those 2 together
variables.css
foo.css:
bar.css
postcss-modules
'scomposes
also inlines the filefoo
, so now I got an@import
that's not at the top of the file, which violates the spec. The (broken) result is something like:Any suggestion on how to address this issue? I'm not using
webpack
(just pure PostCSS). Do I have to write a plugin to dedupe & move imports up top?Thanks!
The text was updated successfully, but these errors were encountered: