-
Notifications
You must be signed in to change notification settings - Fork 6
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
Syntax Error on @container Queries #26
Comments
With [email protected] and [email protected] and postcss = require('postcss');
csso = require('postcss-csso');
postcss([
csso
]).process('@container (min-width: 700px) { .main { color: #FF0000; } } .b { color: rgba(255, 0, 0, 1) }').then((result) => {
console.log(result.css);
// .a,.b{color:red}
}).catch(e => console.error(e)); I'm seeing the following stack trace
Logging the config at function parseToCsso(css, config, postcssNode) {
try {
console.error({config}) produces
EditThe config argument is almost the same as the media equivalent.
Switching the diff --git a/lib/postcssToCsso.js b/lib/postcssToCsso.js
index 315b4ca..77adcf8 100644
--- a/lib/postcssToCsso.js
+++ b/lib/postcssToCsso.js
@@ -50,7 +50,7 @@ function postcssToCsso(node) {
loc: getInfo(node),
name: node.name,
prelude: node.params
- ? parseToCsso(node.params, { context: 'atrulePrelude', atrule: node.name }, node)
+ ? parseToCsso(node.params, { context: 'atrulePrelude', atrule: node.name === 'container' ? 'media' : node.name }, node)
: null,
block: null
};
diff --git a/test/test.js b/test/test.js
index b9cf2ca..94b8ff3 100644
--- a/test/test.js
+++ b/test/test.js
@@ -205,6 +205,14 @@ describe('ast transformations', () => {
[
'.test { padding-top: 1px; padding-right: 2px; padding-bottom: 1px; padding-left: 2px }',
'.test{padding:1px 2px}'
+ ],
+ [
+ '@media (min-width: 600px) { .media { width: 150px} }',
+ '@media (min-width:600px){.media{width:150px}}'
+ ],
+ [
+ '@container (min-width : 700px) { .main { width: 200px } }',
+ '@container (min-width:700px){.main{width:200px}}'
]
]; |
I was also getting the same error but strangely there’s no issue when I run it through the web interface https://css.github.io/csso/csso.html FWIW my project already uses Gulp so I switched to https://github.com/ben-eb/gulp-csso and that seems to work fine. |
i also have this issue in my SvelteKit project |
A similar issue here: vuepress/core#1349 |
Running this issue as well. Using with |
I first became aware of this issue last week when I tried to write @container queries inside Sass files managed by Codekit (which is made by @bdkjones who raised this thread). (I had previously used It’s a shame this issue remains unresolved after 16 months and almost a year after container queries officially arrived in Firefox :( |
Same issue here. |
Same here |
Experiencing this issue using Tailwind’s first-party container queries plugin, compiled via CodeKit. |
I am having the same issue... :( |
In case it helps anyone in this thread … although not Bryan's excellent app :( I’ve moved my CSS compilation to Lightning CSS. |
I am having the same issue... :( |
Still experiencing this issue which, alas, means I can't write container queries. |
It took me 3 hours of searching for information to find the answer, fix it already someone. How to use containers in the end when compiling via sass? |
Same here, with codekit 3.29 |
Same issue. Happens also with container-name: |
How is it possible that after 2 years there's still this issue?? |
Consider this snippet of CSS:
If you attempt to run postcss-csso 6.0.1 on a file containing this snippet, you'll get the following error:
Other PostCSS-based tools such as Autoprefixer and PurgeCSS don't have a problem with
@container
. I'm unsure if the issue lies in the conversion to the csso-compatible AST that postcss-csso performs or if the issue is with CSSO itself. As a first step, I'm filing the report here.The text was updated successfully, but these errors were encountered: