dart-sass problem with imports within absolute path imports
mkobel opened this issue · comments
We use frontend dependencies as webjars.
There we import resources:
@import "/webjars/bootstrap/4.6.0-1/scss/mixins";
The referenced file contains relative imports (e.g. @import "vendor/rfs";
).
This works fine with sass-asset-pipeline, but not with sass-dart-asset-pipeline #287.
The problem can be reproduced even without webjars:
create sass-dart-asset-pipeline/assets/stylesheets/absolute-import/main.scss
:
@import "/bootstrap/bootstrap";
create test in sass-dart-asset-pipeline/src/test/groovy/asset/pipeline/dart/SassProcessorSpec.groovy
void "should compile absolute imports"() {
given:
AssetPipelineConfigHolder.resolvers = []
AssetPipelineConfigHolder.registerResolver(new FileSystemAssetResolver('test','assets'))
def assetFile = AssetHelper.fileForFullName('absolute-import/main.scss')
def processor = new SassProcessor()
when:
def output = processor.process(assetFile.inputStream.text,assetFile)
then:
output.contains('Twitter')
}
Then the test fails (the absolute bootstrap.scss
is found, but inside the import cannot be resolved):
$ ./gradlew :sass-dart-asset-pipeline:test
[...]
> Task :sass-dart-asset-pipeline:test
asset.pipeline.dart.SassProcessorSpec > should compile absolute imports STANDARD_ERROR
[Test worker] ERROR asset.pipeline.dart.SassAssetFileLoader - Unable to find the asset for variables imported by absolute-import//bootstrap/bootstrap
asset.pipeline.dart.SassProcessorSpec > should compile absolute imports FAILED
com.caoccao.javet.exceptions.JavetExecutionException: Error: Cannot invoke method getByteDigest() on null object
╷
8 │ @import "variables";
│ ^^^^^^^^^^^
╵
/bootstrap/bootstrap 8:9 @import
stdin 1:9 root stylesheet
at com.caoccao.javet.interop.V8Runtime.execute(V8Runtime.java:828)
at com.caoccao.javet.interop.executors.V8StringExecutor.execute(V8StringExecutor.java:77)
at com.caoccao.javet.interop.IV8Executable.executeVoid(IV8Executable.java:159)
at asset.pipeline.dart.SassProcessor.process(SassProcessor.groovy:104)
at asset.pipeline.dart.SassProcessorSpec.should compile absolute imports(SassProcessorSpec.groovy:115)
7 tests completed, 1 failed
> Task :sass-dart-asset-pipeline:test FAILED
Is this an sass-dart-asset-pipeline implementation issue or can I fix the behaviour within the project configuration?