@@ -47,7 +47,9 @@ const unplugin = createUnplugin<Options>(
47
47
let mgcStr = new MagicString ( code )
48
48
try {
49
49
// ⭐TODO: 只支持 .vue ? jsx, tsx, js, ts ?
50
- if ( id . endsWith ( '.vue' ) ) {
50
+ // webpack 时 使用 id.includes('vue&type=style') 判断
51
+ if ( id . endsWith ( '.vue' )
52
+ || ( id . includes ( 'vue&type=style' ) && framework === 'webpack' ) ) {
51
53
const { descriptor } = parse ( code )
52
54
const lang = descriptor ?. script ?. lang ?? 'js'
53
55
// ⭐TODO: 只支持 .vue ? jsx, tsx, js, ts ?
@@ -60,12 +62,11 @@ const unplugin = createUnplugin<Options>(
60
62
const variableName = getVariable ( descriptor )
61
63
vbindVariableList . set ( id , matchVariable ( vbindVariableListByPath , variableName ) )
62
64
63
- // TODO: webpack
64
- // 'vite' | 'rollup' | 'esbuild'
65
- if ( ! isServer && framework !== 'webpack' && framework !== 'rspack' )
65
+ if ( ! isServer )
66
66
mgcStr = injectCssOnBuild ( mgcStr , injectCSSContent , descriptor )
67
67
}
68
68
}
69
+
69
70
return {
70
71
code : mgcStr . toString ( ) ,
71
72
get map ( ) {
@@ -117,7 +118,7 @@ const unplugin = createUnplugin<Options>(
117
118
function injectCSSVarsFn ( idKey : string ) {
118
119
const parseRes = parserCompiledSfc ( code )
119
120
const injectRes = injectCSSVars ( vbindVariableList . get ( idKey ) , isScriptSetup , parseRes , mgcStr )
120
- mgcStr = injectRes . mgcStr // .overwrite(0, mgcStr.length(), injectRes.code)
121
+ mgcStr = injectRes . mgcStr
121
122
injectRes . vbindVariableList && vbindVariableList . set ( id , injectRes . vbindVariableList )
122
123
isHmring = false
123
124
}
@@ -137,11 +138,9 @@ const unplugin = createUnplugin<Options>(
137
138
}
138
139
}
139
140
140
- // TODO webpack
141
141
if ( framework === 'webpack' ) {
142
142
if ( id . includes ( 'vue&type=script' ) ) {
143
143
const transId = id . split ( '?vue&type=script' ) [ 0 ]
144
- // TODO 重复注入了
145
144
injectCSSVarsFn ( transId )
146
145
}
147
146
const cssFMM = CSSFileModuleMap . get ( id )
0 commit comments