Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 214b3f1

Browse filesBrowse files
committed
fix: ensure consistent component id across blocks
This fixes the css var injection having different id from generated CSS
1 parent 99a5196 commit 214b3f1
Copy full SHA for 214b3f1

File tree

2 files changed

+10
-6
lines changed
Filter options

2 files changed

+10
-6
lines changed

‎example/App.vue

Copy file name to clipboardExpand all lines: example/App.vue
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import ScriptSetup from './ScriptSetup.vue'
1414
1515
export default {
1616
data() {
17-
return { count: 0 }
17+
return {
18+
count: 0,
19+
color: 'blue'
20+
}
1821
},
1922
components: {
2023
Button,
@@ -26,6 +29,6 @@ export default {
2629
<style scoped>
2730
.logo {
2831
width: 100px;
29-
border: 1px solid red;
32+
border: 1px solid v-bind(color);
3033
}
3134
</style>

‎src/index.ts

Copy file name to clipboardExpand all lines: src/index.ts
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ export default function loader(
9090
const isServer = options.isServerBuild ?? target === 'node'
9191
const isProduction = mode === 'production'
9292

93+
const filename = resourcePath.replace(/\?.*$/, '')
9394
const { descriptor, errors } = parse(source, {
94-
filename: resourcePath,
95+
filename,
9596
sourceMap,
9697
})
9798

9899
// cache descriptor
99-
setDescriptor(resourcePath, descriptor)
100+
setDescriptor(filename, descriptor)
100101

101102
if (errors.length) {
102103
errors.forEach((err) => {
@@ -108,9 +109,9 @@ export default function loader(
108109

109110
// module id for scoped CSS & hot-reload
110111
const rawShortFilePath = path
111-
.relative(rootContext || process.cwd(), resourcePath)
112+
.relative(rootContext || process.cwd(), filename)
112113
.replace(/^(\.\.[\/\\])+/, '')
113-
const shortFilePath = rawShortFilePath.replace(/\\/g, '/') + resourceQuery
114+
const shortFilePath = rawShortFilePath.replace(/\\/g, '/')
114115
const id = hash(
115116
isProduction
116117
? shortFilePath + '\n' + source.replace(/\r\n/g, '\n')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.