@@ -29,19 +29,20 @@ export function extractStyleUrls(
29
29
resolver : UrlResolver , baseUrl : string , cssText : string ) : StyleWithImports {
30
30
const foundUrls : string [ ] = [ ] ;
31
31
32
- const modifiedCssText =
33
- cssText . replace ( CSS_COMMENT_REGEXP , '' ) . replace ( CSS_IMPORT_REGEXP , ( ...m : string [ ] ) => {
34
- const url = m [ 1 ] || m [ 2 ] ;
35
- if ( ! isStyleUrlResolvable ( url ) ) {
36
- // Do not attempt to resolve non-package absolute URLs with URI scheme
37
- return m [ 0 ] ;
38
- }
39
- foundUrls . push ( resolver . resolve ( baseUrl , url ) ) ;
40
- return '' ;
41
- } ) ;
32
+ const modifiedCssText = cssText . replace ( CSS_STRIPPABLE_COMMENT_REGEXP , '' )
33
+ . replace ( CSS_IMPORT_REGEXP , ( ...m : string [ ] ) => {
34
+ const url = m [ 1 ] || m [ 2 ] ;
35
+ if ( ! isStyleUrlResolvable ( url ) ) {
36
+ // Do not attempt to resolve non-package absolute URLs with URI
37
+ // scheme
38
+ return m [ 0 ] ;
39
+ }
40
+ foundUrls . push ( resolver . resolve ( baseUrl , url ) ) ;
41
+ return '' ;
42
+ } ) ;
42
43
return new StyleWithImports ( modifiedCssText , foundUrls ) ;
43
44
}
44
45
45
46
const CSS_IMPORT_REGEXP = / @ i m p o r t \s + (?: u r l \( ) ? \s * (?: (?: [ ' " ] ( [ ^ ' " ] * ) ) | ( [ ^ ; \) \s ] * ) ) [ ^ ; ] * ; ? / g;
46
- const CSS_COMMENT_REGEXP = / \/ \* [ \s \S ] + ?\* \/ / g;
47
+ const CSS_STRIPPABLE_COMMENT_REGEXP = / \/ \* (? ! # \s * (?: s o u r c e U R L | s o u r c e M a p p i n g U R L ) = ) [ \s \S ] + ?\* \/ / g;
47
48
const URL_WITH_SCHEMA_REGEXP = / ^ ( [ ^ : / ? # ] + ) : / ;
0 commit comments