Skip to content

Commit

Permalink
also fix it for the file load
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Jan de Wit <[email protected]>
  • Loading branch information
edewit committed Oct 3, 2024
1 parent 2410879 commit 060e7be
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions esbuild_scss.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,20 @@ func (resolver *NodeModulesImportResolver) CanonicalizeURL(filePath string) (str
}

func (resolver NodeModulesImportResolver) Load(canonicalizedURL string) (godartsass.Import, error) {
path := canonicalizedURL[7:]
u, err := url.Parse(canonicalizedURL)
if err == nil && u.Scheme == "file" {
canonicalizedURL = u.Path
}

content, err := os.ReadFile(path)
content, err := os.ReadFile(canonicalizedURL)
if err != nil {
return godartsass.Import{}, err
}

// Return the parsed import data
return godartsass.Import{
Content: string(content),
SourceSyntax: findSourceSyntax(path),
SourceSyntax: findSourceSyntax(canonicalizedURL),
}, nil
}

Expand Down

0 comments on commit 060e7be

Please sign in to comment.