Skip to content

Commit

Permalink
Issue bertramdev#287: Reverse the import map to make it not be dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
longwa committed Nov 25, 2021
1 parent 641f10f commit 8e60c7e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SassAssetFileLoader {
@V8Function
@SuppressWarnings('unused')
Map resolveImport(String url, String prev, String assetFilePath) {
log.debug("resolving import for url [{}], prev [{}], asset file path [{}]", url, prev, assetFilePath)
log.debug("Resolving import for url [{}], prev [{}], asset file path [{}]", url, prev, assetFilePath)
println " > Importing [${url}], prev [$prev], asset file [${assetFilePath}]"

// The initial import has a path of stdin, but we need to convert that to the proper base path
Expand All @@ -46,7 +46,7 @@ class SassAssetFileLoader {
}
else {
// Resolve the real base path for this import
String priorParent = importMap.find { it.value == prev }?.key
String priorParent = importMap[prev]
if (priorParent) {
Path priorParentPath = Paths.get(priorParent)
if (priorParentPath.parent) {
Expand All @@ -55,7 +55,9 @@ class SassAssetFileLoader {
}
}

importMap[prev] = url
// For each URL remember the last prev, this allows us to resolve nested imports since dart doesn't
// give us the full path when using stdin
importMap[url] = prev

AssetFile imported = getAssetFromScssImport(prev, url)
return [contents: imported.inputStream.text]
Expand Down

0 comments on commit 8e60c7e

Please sign in to comment.