( vars: string[], bindings: BindingMetadata, id: string, isProd: boolean, )
| 164 | cssVarsPlugin.postcss = true |
| 165 | |
| 166 | export function genCssVarsCode( |
| 167 | vars: string[], |
| 168 | bindings: BindingMetadata, |
| 169 | id: string, |
| 170 | isProd: boolean, |
| 171 | ) { |
| 172 | const varsExp = genCssVarsFromList(vars, id, isProd) |
| 173 | const exp = createSimpleExpression(varsExp, false) |
| 174 | const context = createTransformContext(createRoot([]), { |
| 175 | prefixIdentifiers: true, |
| 176 | inline: true, |
| 177 | bindingMetadata: bindings.__isScriptSetup === false ? undefined : bindings, |
| 178 | }) |
| 179 | const transformed = processExpression(exp, context) |
| 180 | const transformedString = |
| 181 | transformed.type === NodeTypes.SIMPLE_EXPRESSION |
| 182 | ? transformed.content |
| 183 | : transformed.children |
| 184 | .map(c => { |
| 185 | return typeof c === 'string' |
| 186 | ? c |
| 187 | : (c as SimpleExpressionNode).content |
| 188 | }) |
| 189 | .join('') |
| 190 | |
| 191 | return `_${CSS_VARS_HELPER}(_ctx => (${transformedString}))` |
| 192 | } |
| 193 | |
| 194 | // <script setup> already gets the calls injected as part of the transform |
| 195 | // this is only for single normal <script> |
no test coverage detected