wip: css var injection production mode

This commit is contained in:
Evan You
2020-11-17 15:58:46 -05:00
parent f92bc5a19a
commit 94736f7729
7 changed files with 96 additions and 19 deletions

View File

@@ -52,7 +52,7 @@ describe('CSS vars injection', () => {
assertCode(content)
})
test('should rewrite CSS vars in scoped mode', () => {
test('should rewrite CSS vars in compileStyle', () => {
const { code } = compileStyle({
source: `.foo {
color: v-bind(color);
@@ -69,6 +69,37 @@ describe('CSS vars injection', () => {
`)
})
test('prod mode', () => {
const { content } = compileSFCScript(
`<script>const a = 1</script>\n` +
`<style>div{
color: v-bind(color);
font-size: v-bind('font.size');
}</style>`,
{ isProd: true }
)
expect(content).toMatch(`_useCssVars(_ctx => ({
"4003f1a6": (_ctx.color),
"41b6490a": (_ctx.font.size)
}))}`)
const { code } = compileStyle({
source: `.foo {
color: v-bind(color);
font-size: v-bind('font.size');
}`,
filename: 'test.css',
id: mockId,
isProd: true
})
expect(code).toMatchInlineSnapshot(`
".foo {
color: var(--4003f1a6);
font-size: var(--41b6490a);
}"
`)
})
describe('codegen', () => {
test('<script> w/ no default export', () => {
assertCode(