From 8e60c7e459ec5d855ce19cffe8c46fec352dfdff Mon Sep 17 00:00:00 2001 From: Aaron Long Date: Thu, 25 Nov 2021 18:23:09 -0500 Subject: [PATCH] Issue #287: Reverse the import map to make it not be dumb --- .../groovy/asset/pipeline/dart/SassAssetFileLoader.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sass-dart-asset-pipeline/src/main/groovy/asset/pipeline/dart/SassAssetFileLoader.groovy b/sass-dart-asset-pipeline/src/main/groovy/asset/pipeline/dart/SassAssetFileLoader.groovy index 48a75b82..0c1fdf73 100644 --- a/sass-dart-asset-pipeline/src/main/groovy/asset/pipeline/dart/SassAssetFileLoader.groovy +++ b/sass-dart-asset-pipeline/src/main/groovy/asset/pipeline/dart/SassAssetFileLoader.groovy @@ -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 @@ -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) { @@ -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]