@@ -111,9 +111,10 @@ export async function compileFile(
111111 const [ clientScript , bindings ] = clientScriptResult
112112 clientCode += clientScript
113113
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 ) {
117118 const ssrScriptResult = await doCompileScript (
118119 store ,
119120 descriptor ,
@@ -127,7 +128,7 @@ export async function compileFile(
127128 ssrCode = `/* SSR compile error: ${ store . state . errors [ 0 ] } */`
128129 }
129130 } else {
130- // when no <script setup> is used, the script result will be identical.
131+ // the script result will be identical.
131132 ssrCode += clientScript
132133 }
133134
@@ -285,6 +286,7 @@ async function doCompileTemplate(
285286 isTS : boolean
286287) {
287288 const templateResult = store . compiler . compileTemplate ( {
289+ isProd : false ,
288290 ...store . options ?. template ,
289291 source : descriptor . template ! . content ,
290292 filename : descriptor . filename ,
@@ -293,7 +295,6 @@ async function doCompileTemplate(
293295 slotted : descriptor . slotted ,
294296 ssr,
295297 ssrCssVars : descriptor . cssVars ,
296- isProd : false ,
297298 compilerOptions : {
298299 ...store . options ?. template ?. compilerOptions ,
299300 bindingMetadata,
0 commit comments