File tree 3 files changed +26
-3
lines changed
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) {
58
58
if ( useSourceMap && typeof btoa === 'function' ) {
59
59
const sourceMapping = toComment ( cssMapping ) ;
60
60
const sourceURLs = cssMapping . sources . map (
61
- ( source ) => `/*# sourceURL=${ cssMapping . sourceRoot } ${ source } */`
61
+ ( source ) => `/*# sourceURL=${ cssMapping . sourceRoot || '' } ${ source } */`
62
62
) ;
63
63
64
64
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; }"`;
8
8
9
9
exports [` api should toString multiple modules 1` ] = ` "body { b : 2 ; } body { a : 1 ; } "` ;
10
10
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
+
11
17
exports [` 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 ; }} "` ;
12
18
13
19
exports [` api should toString with source mapping 1` ] = `
@@ -16,4 +22,4 @@ exports[`api should toString with source mapping 1`] = `
16
22
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC5zY3NzIiwic291cmNlcyI6WyIuL3BhdGgvdG8vdGVzdC5zY3NzIl0sIm1hcHBpbmdzIjoiQUFBQTsiLCJzb3VyY2VSb290Ijoid2VicGFjazovLyJ9 */"
17
23
` ;
18
24
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', () => {
101
101
expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
102
102
} ) ;
103
103
104
- it ( 'should toString without source mapping if btoa not avalibale ' , ( ) => {
104
+ it ( 'should toString without source mapping if btoa not available ' , ( ) => {
105
105
global . btoa = null ;
106
106
107
107
const m = api ( true ) ;
@@ -120,4 +120,21 @@ describe('api', () => {
120
120
121
121
expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
122
122
} ) ;
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
+ } ) ;
123
140
} ) ;
You can’t perform that action at this time.
0 commit comments