@@ -50,7 +50,7 @@ function parseAttributes(str: string) {
50
50
return attrs ;
51
51
}
52
52
53
- async function replaceTagContents ( source , type : 'script' | 'style' , preprocessor : Preprocessor ) {
53
+ async function replaceTagContents ( source , type : 'script' | 'style' , preprocessor : Preprocessor , options : PreprocessOptions ) {
54
54
const exp = new RegExp ( `<${ type } ([\\S\\s]*?)>([\\S\\s]*?)<\\/${ type } >` , 'ig' ) ;
55
55
const match = exp . exec ( source ) ;
56
56
@@ -59,7 +59,8 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor
59
59
const content : string = match [ 2 ] ;
60
60
const processed : { code : string , map ?: SourceMap | string } = await preprocessor ( {
61
61
content,
62
- attributes
62
+ attributes,
63
+ filename : options . filename
63
64
} ) ;
64
65
65
66
if ( processed && processed . code ) {
@@ -77,16 +78,19 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor
77
78
export async function preprocess ( source : string , options : PreprocessOptions ) {
78
79
const { markup, style, script } = options ;
79
80
if ( ! ! markup ) {
80
- const processed : { code : string , map ?: SourceMap | string } = await markup ( { content : source } ) ;
81
+ const processed : { code : string , map ?: SourceMap | string } = await markup ( {
82
+ content : source ,
83
+ filename : options . filename
84
+ } ) ;
81
85
source = processed . code ;
82
86
}
83
87
84
88
if ( ! ! style ) {
85
- source = await replaceTagContents ( source , 'style' , style ) ;
89
+ source = await replaceTagContents ( source , 'style' , style , options ) ;
86
90
}
87
91
88
92
if ( ! ! script ) {
89
- source = await replaceTagContents ( source , 'script' , script ) ;
93
+ source = await replaceTagContents ( source , 'script' , script , options ) ;
90
94
}
91
95
92
96
return {
0 commit comments