From 3de028d0eb647f8871d04b5511bb60d6725edc6e Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Sun, 30 Aug 2020 22:04:35 +0100 Subject: [PATCH] fix: make sourceMaps relative to the CSS output file (#274) Co-authored-by: Ward Peeters --- src/index.js | 2 +- test/__snapshots__/index.test.js.snap | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 495fc920..b82b102c 100644 --- a/src/index.js +++ b/src/index.js @@ -204,7 +204,7 @@ export default (options = {}) => { 'utf8' ).toString('base64')}*/` } else if (sourceMap === true) { - code += `\n/*# sourceMappingURL=${fileName}.map */` + code += `\n/*# sourceMappingURL=${path.basename(fileName)}.map */` } return { diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index d6b4092a..096af22d 100644 --- a/test/__snapshots__/index.test.js.snap +++ b/test/__snapshots__/index.test.js.snap @@ -183,7 +183,7 @@ body { color: red; } -/*# sourceMappingURL=this/is/extracted.css.map */" +/*# sourceMappingURL=extracted.css.map */" `; exports[`extract custom-path: css map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"foo.css\\",\\"bar.css\\",\\"test/fixtures/simple/style.styl\\",\\"style.styl\\",\\"style.sass\\",\\"test/fixtures/simple/style.less\\",\\"style.less\\",\\"style.pcss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,UAAU;AACZ;;ACFA;EACE,UAAU;AACZ;;ACFA;EACE,WAAO;EACP,gBAAY;ACCd;AACA,yDAAyD;ACJzD;EACE,UAAU;EACV,sBAAsB,EAAE;;ACC1B;EACE,cAAA;ACFF;;ACFA;EACE,UAAU;AACZ\\",\\"file\\":\\"this/is/extracted.css\\",\\"sourcesContent\\":[\\"body {\\\\n color: red;\\\\n}\\\\n\\",\\".bar {\\\\n color: red;\\\\n}\\\\n\\",null,null,\\"#sidebar {\\\\n width: 30%;\\\\n background-color: #faa; }\\\\n\\",null,null,\\".pcss {\\\\n color: red;\\\\n}\\\\n\\"]}"`; @@ -281,7 +281,7 @@ body { color: red; } -/*# sourceMappingURL=this/is/extracted.css.map */" +/*# sourceMappingURL=extracted.css.map */" `; exports[`extract relative-path: css map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"foo.css\\",\\"bar.css\\",\\"test/fixtures/simple/style.styl\\",\\"style.styl\\",\\"style.sass\\",\\"test/fixtures/simple/style.less\\",\\"style.less\\",\\"style.pcss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,UAAU;AACZ;;ACFA;EACE,UAAU;AACZ;;ACFA;EACE,WAAO;EACP,gBAAY;ACCd;AACA,yDAAyD;ACJzD;EACE,UAAU;EACV,sBAAsB,EAAE;;ACC1B;EACE,cAAA;ACFF;;ACFA;EACE,UAAU;AACZ\\",\\"file\\":\\"this/is/extracted.css\\",\\"sourcesContent\\":[\\"body {\\\\n color: red;\\\\n}\\\\n\\",\\".bar {\\\\n color: red;\\\\n}\\\\n\\",null,null,\\"#sidebar {\\\\n width: 30%;\\\\n background-color: #faa; }\\\\n\\",null,null,\\".pcss {\\\\n color: red;\\\\n}\\\\n\\"]}"`;