Skip to content

Commit 2ff48f8

Browse files
milahukaisermann
andauthored
fix: [scss] remove sourceMappingURL from result.code (#297)
* sass: remove sourceMappingURL from result.code * Add test for scss srcMap Co-authored-by: Christian Kaisermann <[email protected]>
1 parent f58c6cd commit 2ff48f8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: src/transformers/scss.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const tildeImporter: Importer = (url, prev) => {
3737

3838
const modulePath = join('node_modules', ...url.slice(1).split(/[\\/]/g));
3939

40-
// todo: maybe create a smaller findup utility method?
4140
const foundPath = findUp({ what: modulePath, from: prev });
4241

4342
// istanbul ignore if
@@ -68,6 +67,7 @@ const transformer: Transformer<Options.Sass> = async ({
6867
...options,
6968
includePaths: getIncludePaths(filename, options.includePaths),
7069
outFile: `${filename}.css`,
70+
omitSourceMapUrl: true, // return sourcemap only in result.map
7171
};
7272

7373
const sassOptions = {

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

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { resolve } from 'path';
66
import sveltePreprocess from '../../src';
77
import { preprocess } from '../utils';
88
import type { Options } from '../../src/types';
9+
import { transformer } from '../../src/transformers/scss';
910

1011
const implementation: Options.Sass['implementation'] = {
1112
render(options, callback) {
@@ -121,4 +122,17 @@ describe('transformer - scss', () => {
121122
}</style>"
122123
`);
123124
});
125+
126+
it('returns the source map and removes sourceMappingURL from code', async () => {
127+
const content = 'div{color:red}';
128+
const filename = '/file';
129+
const options = {
130+
sourceMap: true,
131+
};
132+
133+
const { map, code } = await transformer({ content, filename, options });
134+
135+
expect(code).not.toContain('sourceMappingURL');
136+
expect(map).toBeTruthy();
137+
});
124138
});

0 commit comments

Comments
 (0)