Skip to content
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]: Vue CSS v-bind condition is broken by lightningcss #3595

Open
ywenhao opened this issue Sep 29, 2024 · 9 comments
Open

[Bug]: Vue CSS v-bind condition is broken by lightningcss #3595

ywenhao opened this issue Sep 29, 2024 · 9 comments
Assignees
Labels
bug Something isn't working 🎯 upstream

Comments

@ywenhao
Copy link

ywenhao commented Sep 29, 2024

Version

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
    Memory: 2.23 GB / 15.75 GB
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @rsbuild/core: ^1.0.1 => 1.0.8
    @rsbuild/plugin-vue: ^1.0.1 => 1.0.1

Details

<template>
  <div class="content" @click="color = !color">
    <h1>Rsbuild with Vue</h1>
    <p>Start building amazing things with Rsbuild.</p>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const color = ref(true)
</script>

<style scoped>
content h1 {
  font-size: 3.6rem;
  font-weight: 700;
  /* ok */
  color: v-bind("color ? 'red': 'green'");
  /* no ok */
  color: v-bind('color ? "red": "green"');
}
</style>
// mian css
 /* ok */
  color: v-bind("color ? 'red': 'green'");
  /* no ok */
  color: v-bind('color ? "red": "green"');

Reproduce Steps

yarn dev

@ywenhao ywenhao added the bug Something isn't working label Sep 29, 2024
@chenjiahan
Copy link
Member

I tried Vite and this does not work as well, is this a valid syntax in Vue?

image

@ywenhao
Copy link
Author

ywenhao commented Sep 29, 2024

/* no ok */
// color: v-bind('color ? "red": "green"');
image

/* ok */
// color: v-bind("color ? 'red': 'green'");
image

@chenjiahan
Copy link
Member

Have you tried Vite demo?

@ywenhao
Copy link
Author

ywenhao commented Sep 29, 2024

yes , vite demo:
image

image

@chenjiahan
Copy link
Member

I can’t reproduce a similar Vite demo. Can you provide your Vite / Rsbuild demos?

Copy link
Contributor

Hello @ywenhao. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️

@ywenhao
Copy link
Author

ywenhao commented Sep 30, 2024

Hello @ywenhao. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️

[email protected]:ywenhao/rsbuild-vue-css-demo.git

vite-demo
https://stackblitz.com/edit/vitejs-vite-aw9yet?file=src%2FApp.vue

Copy link
Contributor

github-actions bot commented Oct 6, 2024

As the issue was labelled with need reproduction, but no response in 5 days. This issue will be closed. Feel free to comment and reopen it if you have any further questions. For background, see Why reproductions are required.

由于该 issue 被标记为 "需要重现",但在 5 天内没有回应,因此该 issue 将被关闭。如果你有任何进一步的问题,请随时发表评论并重新打开该 issue。背景请参考 为什么需要最小重现

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2024
@chenjiahan chenjiahan reopened this Oct 6, 2024
@chenjiahan
Copy link
Member

The style is broken by lightningcss-loader.

  • lightningcssLoader: false:
h1[data-v-7ba5bd90] {
  color: var(--7ba5bd90-color\ \?\ \"red\"\:\ \"green\");
}
  • lightningcssLoader: true
h1[data-v-7ba5bd90] {
  color: var(--7ba5bd90-color\ \?\ \\\"red\\\"\:\ \\\"green\\\");
}

@GiveMe-A-Name can you help to fix this? ❤️

@chenjiahan chenjiahan changed the title [Bug]: vue css v-bind is no ok [Bug]: Vue CSS v-bind condition is broken by lightningcss Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🎯 upstream
Projects
None yet
Development

No branches or pull requests

3 participants