File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ function cssWithMappingToString(item, useSourceMap) {
5858 if ( useSourceMap && typeof btoa === 'function' ) {
5959 const sourceMapping = toComment ( cssMapping ) ;
6060 const sourceURLs = cssMapping . sources . map (
61- ( source ) => `/*# sourceURL=${ cssMapping . sourceRoot } ${ source } */`
61+ ( source ) => `/*# sourceURL=${ cssMapping . sourceRoot || '' } ${ source } */`
6262 ) ;
6363
6464 return [ content ]
Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ exports[`api should toString a single module 1`] = `"body { a: 1; }"`;
88
99exports [` api should toString multiple modules 1` ] = ` "body { b : 2 ; } body { a : 1 ; } "` ;
1010
11+ exports [` api should toString with a source map without "sourceRoot" 1` ] = `
12+ "body { a : 1 ; }
13+ /*# sourceURL=./path/to/test.scss */
14+ /*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC5zY3NzIiwic291cmNlcyI6WyIuL3BhdGgvdG8vdGVzdC5zY3NzIl0sIm1hcHBpbmdzIjoiQUFBQTsifQ== */"
15+ ` ;
16+
1117exports [` api should toString with media query 1` ] = ` "body { b : 2 ; } body { c : 3 ; } body { b : 2 ; } @media print { body { b: 2 ; }} @media print { body { d: 4 ; }} @media screen { body { a: 1 ; }} "` ;
1218
1319exports [` api should toString with source mapping 1` ] = `
@@ -16,4 +22,4 @@ exports[`api should toString with source mapping 1`] = `
1622/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC5zY3NzIiwic291cmNlcyI6WyIuL3BhdGgvdG8vdGVzdC5zY3NzIl0sIm1hcHBpbmdzIjoiQUFBQTsiLCJzb3VyY2VSb290Ijoid2VicGFjazovLyJ9 */"
1723` ;
1824
19- exports [` api should toString without source mapping if btoa not avalibale 1` ] = ` "body { a : 1 ; } "` ;
25+ exports [` api should toString without source mapping if btoa not available 1` ] = ` "body { a : 1 ; } "` ;
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ describe('api', () => {
101101 expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
102102 } ) ;
103103
104- it ( 'should toString without source mapping if btoa not avalibale ' , ( ) => {
104+ it ( 'should toString without source mapping if btoa not available ' , ( ) => {
105105 global . btoa = null ;
106106
107107 const m = api ( true ) ;
@@ -120,4 +120,21 @@ describe('api', () => {
120120
121121 expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
122122 } ) ;
123+
124+ it . only ( 'should toString with a source map without "sourceRoot"' , ( ) => {
125+ const m = api ( true ) ;
126+
127+ m . push ( [
128+ 1 ,
129+ 'body { a: 1; }' ,
130+ '' ,
131+ {
132+ file : 'test.scss' ,
133+ sources : [ './path/to/test.scss' ] ,
134+ mappings : 'AAAA;' ,
135+ } ,
136+ ] ) ;
137+
138+ expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
139+ } ) ;
123140} ) ;
You can’t perform that action at this time.
0 commit comments