-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
🐛 BUG: Astro 1-beta42 re-introduces a PostCSS Preset Env's Custom Media Queries bug #3648
Comments
Thanks for the thorough issue @djmtype! I see two changes from
Can confirm this issue occurs in CSS files imported via frontmatter as well (reproduction) |
Honestly, just found it more reliable to add this configuration to postcss.config.js. const postcssPresetEnv = require("postcss-preset-env")
module.exports = {
plugins: [
postcssPresetEnv({
stage: 0,
features: {
"custom-media-queries": {
importFrom: ["./node_modules/open-props/src/props.media.css"],
},
},
}),
],
} |
Appears to be an underlying Vite issue. Here's a recreation here: https://stackblitz.com/edit/vitejs-vite-rhhiwt?file=index.html,package.json,style.css,postcss.config.js&terminal=dev Should we document the workaround somewhere? Going to close this issue as it doesn't appear we can fix it. |
Import from has been deprecated according to the PostCSS console logs I'm getting. My most reliable workaround now is to import the variables into all scoped styles, not sure why it doesn't just work importing it into my layout. @import "../../styles/variables.css"; I'm just using custom media queries but not open props. |
Is importing the stylesheet in every component the only workaround? Has someone found any other solution? Thanks in advance. |
I'm facing the same problem. Should this issue be re-opened or another one created? |
Would be awesome if we didn’t have to do this, yes I am having to import into each and every component.
…On Thu, Apr 27 2023 at 4:26 pm, David Sandoz < ***@***.*** > wrote:
I'm facing the same problem. Should this issue be re-opened or another one
created?
—
Reply to this email directly, view it on GitHub (
#3648 (comment) ) ,
or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AF7VYSZTI7XN6Q3GHSPCT3LXDKF2DANCNFSM5ZJJWLUQ
).
You are receiving this because you commented. Message ID: <withastro/astro/issues/3648/1525898901
@ github. com>
|
It does not work with NextJs. |
What version of
astro
are you using?1.0.0-beta.46
Are you using an SSR adapter? If so, which one?
none
What package manager are you using?
npm
What operating system are you using?
mac
Describe the Bug
I'm using Open-Props library which relies heavily on the PostCSS Import plugin and the PostCSS Preset Env plugin. This bug is not exclusive to Open-Props BTW.
It utilizes media query ranges and custom media queries. Those properties can be seen here: https://github.com/argyleink/open-props/blob/main/src/props.media.css
The following example no longer works in Astro 1-beta 42 and later, but works as expected in Astro 1-beta 41.
The workaround would be to include the custom media query definition(s) (This file) in every single Astro component wherever custom media queries are used. However, that would be entirely tedious, redundant and bloated because the bug only persists during development, and not at build.
In the Stackblitz example, expand the viewport beyond 480px wide, and there should be a gradient background, however, the background remains white. This is the bug.
Uncomment
@custom-media --sm-n-above (width >= 480px)
as a workaround to see that PostCSS Env's custom media queries do work.This bug is tricky because if you comment out
@custom-media --sm-n-above (width >= 480px)
once again, everything will continue working.However, kill and restart the server and you'll see the issue again.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-3pb6hh?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: