-
-
Notifications
You must be signed in to change notification settings - Fork 835
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
Nuxt3 - @apply directives in <style> not correctly parsed in production #1849
Comments
yeah! exact same case here for @screen |
Hi, i found it works well with CSR, without |
So I encountered same issue too. My walkaround was to use the /** instead of this **/
.test2 {
@apply bg-green4;
}
/** do this **/
.test2 {
--at-apply: "bg-green4";
} This works fine without any issues but of-course you'll have to opt-in to this feature with the transformerDirectives transformer set in your config import { transformerDirectives() } from "unocss"
export default defineConfig({
transformers: [transformerDirectives()]
}) |
@therealokoro Thank you that does work. I tried debugging a little bit more. I am wondering when is the MagicString generated? I commented out WARN warnings when minifying css: 14:52:27
▲ [WARNING] Expected ";" but found "}" [css-syntax-error]
<stdin>:1:29:
1 │ .test,.test2{@apply bg-green4}.test3{background-color:orange}.test5...
│ ^
╵ ; As you can see, it is trying to minify Is this a Nuxt3 / bundlers bug? Thank you |
@wister i'm glad the walkaround worked for you. Until this is fixed I guess this will be the only way to use it. |
Same issue for me, @therealokoro thanks for the temporary workaround! |
@maoosi my pleasure. I think it's worth mentioning that this isn't even a nuxt3 issue. I encountered this problem while using plain vue 3 |
Any news on this? |
Ran into this today, too... There's a workaround! Phew 😅. |
... workaround for unocss weird bug (unocss/unocss#1849)
The docs here: https://github.com/unocss/unocss/tree/main/packages/transformer-directives tells you to quote values that contain Bug? 🤷♂️ |
You can fix this issue by enforcing transformers: [
transformerDirectives({ enforce: 'pre' }),
], Or, you could disable cssnano postcss: {
plugins: {
cssnano: {
preset: ['default', {
mergeRules: false,
}],
},
},
}, |
Yeah thats true @sibbng I remember using this fix in one of my old projects. Totally forgot about it. Thanks mate |
Nuxt 3.0.0-rc.13 and unocss 0.46.3
Problem: The
@apply
directives inside<style>
tag in SFC in Nuxt3 are not correctly parsed when inPRODUCTION
. For some reason when there are multiple selectors that use@apply
, the selectors are grouped and the styles are from the last selector. For example:This will generate the MagicString
.test,.test2{@apply bg-green4}
for thetransformerDirectives()
function.When there is another style that does not use
@apply
between the ones that do. The styles will result correctly parsed. For example:Reproduction: https://stackblitz.com/edit/github-zoupmi?file=components%2FTest.vue (fork of https://github.com/antfu/vitesse-nuxt3)
The
Test.vue
SFC is correctly parsed when inDEVELOPMENT
I believe this might be a
core
bug?Thank you for your time
The text was updated successfully, but these errors were encountered: