From feba02a124bbd8767f29c8944b76136beecc9aaa Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Fri, 24 Apr 2020 19:07:25 +0100 Subject: [PATCH 1/2] Always make sourcemap path relative to css output file --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index a6920efe..795d02ca 100644 --- a/src/index.js +++ b/src/index.js @@ -175,7 +175,7 @@ export default (options = {}) => { 'utf8' ).toString('base64')}*/` } else if (sourceMap === true) { - code += `\n/*# sourceMappingURL=${fileName}.map */` + code += `\n/*# sourceMappingURL=${path.basename(fileName)}.map */` } return { From c4304f155b4ea09a1417902b13aa02c29191de0d Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Fri, 24 Apr 2020 19:08:40 +0100 Subject: [PATCH 2/2] Update snapshots Now shows relative sourceMappingURL, rather than duplicating the full filePath --- test/__snapshots__/index.test.js.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/__snapshots__/index.test.js.snap b/test/__snapshots__/index.test.js.snap index 35da34d2..3df4bcf9 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\\"]}"`; @@ -221,7 +221,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\\"]}"`;