feat: ssr support for <style vars>

This commit is contained in:
Evan You
2020-07-12 18:04:09 -04:00
parent b6cdd5621e
commit b9595e64cf
17 changed files with 256 additions and 15 deletions

View File

@@ -204,10 +204,11 @@ export function generate(
genFunctionPreamble(ast, context)
}
// enter render function
// binding optimizations
const optimizeSources = options.bindingMetadata
? `, $props, $setup, $data, $options`
: ``
// enter render function
if (!ssr) {
if (genScopeId) {
push(`const render = ${PURE_ANNOTATION}_withId(`)

View File

@@ -126,6 +126,11 @@ export interface TransformOptions {
* `ssrRender` option instead of `render`.
*/
ssr?: boolean
/**
* SFC <style vars> injection string
* needed to render inline CSS variables on component root
*/
ssrCssVars?: string
/**
* Optional binding metadata analyzed from script - used to optimize
* binding access when `prefixIdentifiers` is enabled.

View File

@@ -120,6 +120,7 @@ export function createTransformContext(
expressionPlugins = [],
scopeId = null,
ssr = false,
ssrCssVars = ``,
bindingMetadata = {},
onError = defaultOnError
}: TransformOptions
@@ -136,6 +137,7 @@ export function createTransformContext(
expressionPlugins,
scopeId,
ssr,
ssrCssVars,
bindingMetadata,
onError,
@@ -148,7 +150,7 @@ export function createTransformContext(
imports: new Set(),
temps: 0,
cached: 0,
identifiers: {},
identifiers: Object.create(null),
scopes: {
vFor: 0,
vSlot: 0,