MCPcopy
hub / github.com/vuejs/core / genCssVarsCode

Function genCssVarsCode

packages/compiler-sfc/src/style/cssVars.ts:166–192  ·  view source on GitHub ↗
(
  vars: string[],
  bindings: BindingMetadata,
  id: string,
  isProd: boolean,
)

Source from the content-addressed store, hash-verified

164cssVarsPlugin.postcss = true
165
166export 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>

Callers 2

compileScriptFunction · 0.90

Calls 6

genCssVarsFromListFunction · 0.85
createSimpleExpressionFunction · 0.85
createTransformContextFunction · 0.85
processExpressionFunction · 0.85
mapMethod · 0.80
createRootFunction · 0.50

Tested by

no test coverage detected