@@ -26,6 +26,10 @@ type Options struct {
26
26
Reporter Reporter
27
27
28
28
Transforms transforms.Options
29
+
30
+ // Resolver is a path resolver. If not specified, the default node-style
31
+ // resolver will be used.
32
+ Resolver Resolver
29
33
}
30
34
31
35
func newCompilation (opts Options ) * compilation {
@@ -38,12 +42,17 @@ func newCompilation(opts Options) *compilation {
38
42
result : newResult (),
39
43
reporter : logging .DefaultReporter ,
40
44
transforms : opts .Transforms ,
45
+ resolver : & NodeResolver {},
41
46
}
42
47
43
48
if opts .Reporter != nil {
44
49
c .reporter = opts .Reporter
45
50
}
46
51
52
+ if opts .Resolver != nil {
53
+ c .resolver = opts .Resolver
54
+ }
55
+
47
56
return c
48
57
}
49
58
@@ -169,7 +178,12 @@ func (c *compilation) parseFile(file string, hasOutput bool) *ast.Stylesheet {
169
178
var wg errgroup.Group
170
179
for _ , imp := range ss .Imports {
171
180
wg .Go (func () error {
172
- rel := filepath .Join (filepath .Dir (source .Path ), imp .Value )
181
+ rel , err := c .resolver .Resolve (imp .Value , filepath .Dir (source .Path ))
182
+ if err != nil {
183
+ c .addError (err )
184
+ return nil
185
+ }
186
+
173
187
// If import follow is on, then every referenced file makes it to the output.
174
188
imported := c .parseFile (rel , c .transforms .ImportRules == transforms .ImportRulesFollow )
175
189
0 commit comments