Skip to content

Commit bd1caca

Browse files
committed
fix: 🐛 rename scss prepend option from data to prependData
Aligning the prop value with the [`sass-loader`](https://webpack.js.org/loaders/sass-loader/) option. BREAKING CHANGE: 🧨 Content passed through the `data` property won't be prepended anymore.
1 parent 630f0e7 commit bd1caca

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

Diff for: src/modules/typescript/compileFromMemory.ts

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function createImportTransformerFromProgram(program: ts.Program) {
114114
continue;
115115
}
116116
}
117+
117118
newElements.push(spec);
118119
}
119120

Diff for: src/transformers/scss.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ const transformer: Transformer<Options.Sass> = async ({
3434
implementation = sass = mod.default;
3535
}
3636

37-
const { renderSync, ...sassOptions }: Options.Sass = {
37+
const { renderSync, prependData, ...restOptions } = {
3838
sourceMap: true,
3939
...options,
4040
includePaths: getIncludePaths(filename, options.includePaths),
4141
outFile: `${filename}.css`,
4242
};
4343

44-
sassOptions.data = options.data ? options.data + content : content;
44+
const sassOptions = {
45+
...restOptions,
46+
data: prependData ? prependData + content : content,
47+
};
4548

4649
// scss errors if passed an empty string
4750
if (sassOptions.data.length === 0) {

Diff for: src/types/options.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ export interface Babel extends BabelOptions {
2626
}
2727

2828
export type Pug = PugOptions;
29-
export type Sass = Omit<SassOptions, 'file'> & {
29+
export type Sass = Omit<SassOptions, 'file' | 'data'> & {
3030
implementation?: {
3131
render?: typeof render;
3232
renderSync?: typeof renderSync;
3333
};
3434
renderSync?: boolean;
35+
prependData?: string;
3536
};
3637
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/less/index.d.ts#L80
3738
export interface Less {

Diff for: test/fixtures/types.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export type AType = "test1" | "test2"
1+
export type AType = 'test1' | 'test2';
22
export interface AInterface {
3-
test: string
3+
test: string;
44
}
5-
export const AValue: string = "test"
5+
export const AValue: string = 'test';
66

7-
export default "String"
7+
export default 'String';

Diff for: test/transformers/scss.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('transformer - scss', () => {
3434
const template = `<style lang="scss"></style>`;
3535
const opts = getAutoPreprocess({
3636
scss: {
37-
data: '$color:red;div{color:$color}',
37+
prependData: '$color:red;div{color:$color}',
3838
},
3939
});
4040

@@ -70,7 +70,7 @@ describe('transformer - scss', () => {
7070
const template = `<style lang="scss"></style>`;
7171
const opts = getAutoPreprocess({
7272
scss: {
73-
data: '$color:blue;div{color:$color}',
73+
prependData: '$color:blue;div{color:$color}',
7474
renderSync: true,
7575
},
7676
});

0 commit comments

Comments
 (0)