Skip to content

Commit e57af2e

Browse files
authored
fix(plugin-vue): regenerate scoped css in build watch, fix #7980 (#7989)
1 parent c5f46d2 commit e57af2e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: packages/plugin-vue/src/main.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async function genTemplateCode(
269269
? `&src=${descriptor.id}`
270270
: '&src=true'
271271
: ''
272-
const scopedQuery = hasScoped ? `&scoped=true` : ``
272+
const scopedQuery = hasScoped ? `&scoped=${descriptor.id}` : ``
273273
const attrsQuery = attrsToQuery(template.attrs, 'js', true)
274274
const query = `?vue&type=template${srcQuery}${scopedQuery}${attrsQuery}`
275275
const request = JSON.stringify(src + query)
@@ -356,7 +356,8 @@ async function genStyleCode(
356356
: '&src=true'
357357
: ''
358358
const directQuery = asCustomElement ? `&inline` : ``
359-
const query = `?vue&type=style&index=${i}${srcQuery}${directQuery}`
359+
const scopedQuery = style.scoped ? `&scoped=${descriptor.id}` : ``
360+
const query = `?vue&type=style&index=${i}${srcQuery}${directQuery}${scopedQuery}`
360361
const styleRequest = src + query + attrsQuery
361362
if (style.module) {
362363
if (asCustomElement) {
@@ -457,7 +458,7 @@ async function linkSrcToDescriptor(
457458

458459
// these are built-in query parameters so should be ignored
459460
// if the user happen to add them as attrs
460-
const ignoreList = ['id', 'index', 'src', 'type', 'lang', 'module']
461+
const ignoreList = ['id', 'index', 'src', 'type', 'lang', 'module', 'scoped']
461462

462463
function attrsToQuery(
463464
attrs: SFCBlock['attrs'],

0 commit comments

Comments
 (0)