@@ -50,7 +50,7 @@ function parseAttributes(str: string) {
5050 return attrs ;
5151}
5252
53- async function replaceTagContents ( source , type : 'script' | 'style' , preprocessor : Preprocessor ) {
53+ async function replaceTagContents ( source , type : 'script' | 'style' , preprocessor : Preprocessor , options : PreprocessOptions ) {
5454 const exp = new RegExp ( `<${ type } ([\\S\\s]*?)>([\\S\\s]*?)<\\/${ type } >` , 'ig' ) ;
5555 const match = exp . exec ( source ) ;
5656
@@ -59,7 +59,8 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor
5959 const content : string = match [ 2 ] ;
6060 const processed : { code : string , map ?: SourceMap | string } = await preprocessor ( {
6161 content,
62- attributes
62+ attributes,
63+ filename : options . filename
6364 } ) ;
6465
6566 if ( processed && processed . code ) {
@@ -77,16 +78,19 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor
7778export async function preprocess ( source : string , options : PreprocessOptions ) {
7879 const { markup, style, script } = options ;
7980 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+ } ) ;
8185 source = processed . code ;
8286 }
8387
8488 if ( ! ! style ) {
85- source = await replaceTagContents ( source , 'style' , style ) ;
89+ source = await replaceTagContents ( source , 'style' , style , options ) ;
8690 }
8791
8892 if ( ! ! script ) {
89- source = await replaceTagContents ( source , 'script' , script ) ;
93+ source = await replaceTagContents ( source , 'script' , script , options ) ;
9094 }
9195
9296 return {
0 commit comments