@@ -859,15 +859,26 @@ type PreprocessorAdditionalData =
859
859
| string
860
860
| ( ( source : string , filename : string ) => string | Promise < string > )
861
861
862
+ type StylePreprocessorOptions = {
863
+ [ key : string ] : any
864
+ additionalData ?: PreprocessorAdditionalData
865
+ filename : string
866
+ alias : Alias [ ]
867
+ }
868
+
869
+ type SassStylePreprocessorOptions = StylePreprocessorOptions & Sass . Options
870
+
862
871
type StylePreprocessor = (
863
872
source : string ,
864
873
root : string ,
865
- options : {
866
- [ key : string ] : any
867
- additionalData ?: PreprocessorAdditionalData
868
- filename : string
869
- alias : Alias [ ]
870
- } ,
874
+ options : StylePreprocessorOptions ,
875
+ resolvers : CSSAtImportResolvers
876
+ ) => StylePreprocessorResults | Promise < StylePreprocessorResults >
877
+
878
+ type SassStylePreprocessor = (
879
+ source : string ,
880
+ root : string ,
881
+ options : SassStylePreprocessorOptions ,
871
882
resolvers : CSSAtImportResolvers
872
883
) => StylePreprocessorResults | Promise < StylePreprocessorResults >
873
884
@@ -902,7 +913,12 @@ function loadPreprocessor(lang: PreprocessLang, root: string): any {
902
913
}
903
914
904
915
// .scss/.sass processor
905
- const scss : StylePreprocessor = async ( source , root , options , resolvers ) => {
916
+ const scss : SassStylePreprocessor = async (
917
+ source ,
918
+ root ,
919
+ options ,
920
+ resolvers
921
+ ) => {
906
922
const render = loadPreprocessor ( PreprocessLang . sass , root ) . render
907
923
const internalImporter : Sass . Importer = ( url , importer , done ) => {
908
924
resolvers . sass ( url , importer ) . then ( ( resolved ) => {
@@ -913,12 +929,19 @@ const scss: StylePreprocessor = async (source, root, options, resolvers) => {
913
929
}
914
930
} )
915
931
}
932
+ const importer = [ internalImporter ]
933
+ if ( options . importer ) {
934
+ Array . isArray ( options . importer )
935
+ ? importer . concat ( options . importer )
936
+ : importer . push ( options . importer )
937
+ }
938
+
916
939
const finalOptions : Sass . Options = {
917
940
...options ,
918
941
data : await getSource ( source , options . filename , options . additionalData ) ,
919
942
file : options . filename ,
920
943
outFile : options . filename ,
921
- importer : [ internalImporter ] . concat ( options . importer )
944
+ importer
922
945
}
923
946
924
947
try {
@@ -946,7 +969,7 @@ const scss: StylePreprocessor = async (source, root, options, resolvers) => {
946
969
}
947
970
}
948
971
949
- const sass : StylePreprocessor = ( source , root , options , aliasResolver ) =>
972
+ const sass : SassStylePreprocessor = ( source , root , options , aliasResolver ) =>
950
973
scss (
951
974
source ,
952
975
root ,
0 commit comments