@@ -111,9 +111,10 @@ export async function compileFile(
111
111
const [ clientScript , bindings ] = clientScriptResult
112
112
clientCode += clientScript
113
113
114
- // script ssr only needs to be performed if using <script setup> where
115
- // the render fn is inlined.
116
- if ( descriptor . scriptSetup ) {
114
+ // script ssr needs to be performed if :
115
+ // 1.using <script setup> where the render fn is inlined.
116
+ // 2.using cssVars, as it do not need to be injected during SSR.
117
+ if ( descriptor . scriptSetup || descriptor . cssVars . length > 0 ) {
117
118
const ssrScriptResult = await doCompileScript (
118
119
store ,
119
120
descriptor ,
@@ -127,7 +128,7 @@ export async function compileFile(
127
128
ssrCode = `/* SSR compile error: ${ store . state . errors [ 0 ] } */`
128
129
}
129
130
} else {
130
- // when no <script setup> is used, the script result will be identical.
131
+ // the script result will be identical.
131
132
ssrCode += clientScript
132
133
}
133
134
@@ -285,6 +286,7 @@ async function doCompileTemplate(
285
286
isTS : boolean
286
287
) {
287
288
const templateResult = store . compiler . compileTemplate ( {
289
+ isProd : false ,
288
290
...store . options ?. template ,
289
291
source : descriptor . template ! . content ,
290
292
filename : descriptor . filename ,
@@ -293,7 +295,6 @@ async function doCompileTemplate(
293
295
slotted : descriptor . slotted ,
294
296
ssr,
295
297
ssrCssVars : descriptor . cssVars ,
296
- isProd : false ,
297
298
compilerOptions : {
298
299
...store . options ?. template ?. compilerOptions ,
299
300
bindingMetadata,
0 commit comments