From 4ba3710fab61dbed3f2cce07135daa5953e72785 Mon Sep 17 00:00:00 2001 From: milahu Date: Wed, 6 Jan 2021 21:27:59 +0100 Subject: [PATCH 1/2] sass: remove sourceMappingURL from result.code --- src/transformers/scss.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/transformers/scss.ts b/src/transformers/scss.ts index 9aee568e..4985940c 100644 --- a/src/transformers/scss.ts +++ b/src/transformers/scss.ts @@ -68,6 +68,7 @@ const transformer: Transformer = async ({ ...options, includePaths: getIncludePaths(filename, options.includePaths), outFile: `${filename}.css`, + omitSourceMapUrl: true, // return sourcemap only in result.map }; const sassOptions = { From 96205d9542d347cfa53afec36200e6fee9f701ed Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Fri, 29 Jan 2021 07:32:45 -0300 Subject: [PATCH 2/2] Add test for scss srcMap --- src/transformers/scss.ts | 1 - test/transformers/scss.test.ts | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/transformers/scss.ts b/src/transformers/scss.ts index 4985940c..80790d11 100644 --- a/src/transformers/scss.ts +++ b/src/transformers/scss.ts @@ -37,7 +37,6 @@ const tildeImporter: Importer = (url, prev) => { const modulePath = join('node_modules', ...url.slice(1).split(/[\\/]/g)); - // todo: maybe create a smaller findup utility method? const foundPath = findUp({ what: modulePath, from: prev }); // istanbul ignore if diff --git a/test/transformers/scss.test.ts b/test/transformers/scss.test.ts index 62873aab..b2539e68 100644 --- a/test/transformers/scss.test.ts +++ b/test/transformers/scss.test.ts @@ -6,6 +6,7 @@ import { resolve } from 'path'; import sveltePreprocess from '../../src'; import { preprocess } from '../utils'; import type { Options } from '../../src/types'; +import { transformer } from '../../src/transformers/scss'; const implementation: Options.Sass['implementation'] = { render(options, callback) { @@ -121,4 +122,17 @@ describe('transformer - scss', () => { }" `); }); + + it('returns the source map and removes sourceMappingURL from code', async () => { + const content = 'div{color:red}'; + const filename = '/file'; + const options = { + sourceMap: true, + }; + + const { map, code } = await transformer({ content, filename, options }); + + expect(code).not.toContain('sourceMappingURL'); + expect(map).toBeTruthy(); + }); });