Skip to content

[Bug] Scoped css not work in webpack examples #187

@Timeless0911

Description

@Timeless0911

Describe the bug

In a webpack example with scoped css in sfc, the css does not have scopeId binded.

<script setup lang="ts">
import { ref } from 'vue'
const msg = ref('')
</script>

<template>
  <div>
    <h1 class="text-red">Hello world</h1>
    <h2>{{ msg }}</h2>
    <input v-model="msg" type="text" />
  </div>
</template>

<style scoped>
.text-red {
  color: red;
}
</style>

Image

Actual

.text-red {
  color: red;
}

Expected

.text-red[data-v-abcdefgh] {
  color: red;
}

Reproduction

https://github.com/unplugin/unplugin-vue/tree/main/examples/webpack

System Info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 160.47 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.10.0 - ~/Library/Caches/fnm_multishells/1084_1747037734148/bin/node
    Yarn: 1.22.22 - ~/Library/Caches/fnm_multishells/1084_1747037734148/bin/yarn
    npm: 10.9.0 - ~/Library/Caches/fnm_multishells/1084_1747037734148/bin/npm
    pnpm: 10.12.4 - ~/Library/Caches/fnm_multishells/1084_1747037734148/bin/pnpm
    bun: 1.1.30 - ~/.bun/bin/bun
  Browsers:
    Chrome: 137.0.7151.120
    Safari: 17.6

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions