@@ -9,9 +9,9 @@ import * as atUrl from 'postcss-url';
99import ( 'postcss-url/src/type/custom' ) ;
1010
1111export interface PostConfig {
12- importResolve : ( key : string , dir : string ) => string | Promise < string > ;
12+ importResolve : ( importKey : string , baseKey : string ) => string | Promise < string > ;
1313 importLoad : ( key : string ) => string | Promise < string > ;
14- urlResolve : ( key : string , isLocal : boolean ) => string ;
14+ urlResolve : ( importKey : string , baseKey : string ) => string ;
1515 minify ?: boolean ;
1616}
1717
@@ -25,10 +25,10 @@ export class PostBuilder {
2525 }
2626 }
2727
28- build ( key : string , baseKey : string ) {
29- return postcss ( this . pluginList ) . process ( '@import "' + key + '"' , {
28+ build ( code : string , key : string ) {
29+ return postcss ( this . pluginList ) . process ( code , {
3030 parser : safeParser ,
31- from : baseKey ,
31+ from : key ,
3232 map : {
3333 inline : false ,
3434 sourcesContent : false
@@ -42,10 +42,9 @@ export class PostBuilder {
4242 load : this . config . importLoad
4343 } ) ,
4444 atUrl ( {
45- url : ( ( asset ) => {
46- const isLocal = ! ! asset . pathname ;
47- return this . config . urlResolve ( isLocal ? asset . absolutePath ! : asset . url , isLocal ) ;
48- } ) as atUrl . CustomTransformFunction
45+ url : ( ( asset : any , dir : any , opts : any , decl : any ) =>
46+ this . config . urlResolve ( asset . url , decl . source . input . file )
47+ ) as atUrl . CustomTransformFunction
4948 } ) ,
5049 autoprefixer
5150 ] ;
0 commit comments