diff --git a/src/compiler.ts b/src/compiler.ts index 0749263..ca11eb7 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -168,8 +168,14 @@ export class SFCCompiler { ] .concat(this.style.postcssPlugins) .filter(Boolean) + const preprocessOptions = + (style.lang && + this.style.preprocessOptions && + this.style.preprocessOptions[style.lang]) || + {} + const source = style.src ? this.read(style.src, filename) : style.content const result = compileStyle({ - source: style.src ? this.read(style.src, filename) : style.content, + source: preprocessOptions.data ? `${preprocessOptions.data}\n${source}` : source, filename, id: scopeId, map: style.map, @@ -177,11 +183,7 @@ export class SFCCompiler { postcssPlugins, postcssOptions: this.style.postcssOptions, preprocessLang: style.lang, - preprocessOptions: - (style.lang && - this.style.preprocessOptions && - this.style.preprocessOptions[style.lang]) || - {}, + preprocessOptions, trim: this.style.trim }) diff --git a/test/compile.spec.ts b/test/compile.spec.ts new file mode 100644 index 0000000..68f1f40 --- /dev/null +++ b/test/compile.spec.ts @@ -0,0 +1,18 @@ +import {createDefaultCompiler} from "../src" + +it('should prepend data scss option to actual style', () => { + const compiler = createDefaultCompiler({ + style: { + preprocessOptions : { + scss: { + data: `$testColor: red;` + } + } + } + }) + const result = compiler.compileStyle('foo.vue', 'foo', + {type: 'style', lang: 'scss', content: '.foo_0{ color: $testColor }', map: undefined, attrs: {}, start: 1, end: 1} + ); + + expect(result.code).toEqual(expect.stringContaining('color: red')) +}) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy