Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-sfc): user-defined options.data of scss should be respected #1952

Merged
merged 3 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/compiler-sfc/__tests__/compileStyle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,26 @@ describe('SFC style preprocessors', () => {
path.join(__dirname, './fixture/import.scss')
])
})

test('scss respect user-defined options.additionalData', () => {
const res = compileStyle({
preprocessOptions: {
additionalData: `
@mixin square($size) {
width: $size;
height: $size;
}`
},
source: `
.square {
@include square(100px);
}
`,
filename: path.resolve(__dirname, './fixture/test.scss'),
id: '',
preprocessLang: 'scss'
})

expect(res.errors.length).toBe(0)
})
})
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/stylePreprocessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const scss: StylePreprocessor = (source, map, options, load = require) => {
const nodeSass = load('sass')
const finalOptions = {
...options,
data: source,
data: (options.additionalData || '') + source,
file: options.filename,
outFile: options.filename,
sourceMap: !!map
Expand Down