Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart-sass problem with imports within absolute path imports #297

Closed
mkobel opened this issue Mar 1, 2022 · 0 comments · Fixed by #299
Closed

dart-sass problem with imports within absolute path imports #297

mkobel opened this issue Mar 1, 2022 · 0 comments · Fixed by #299

Comments

@mkobel
Copy link
Contributor

mkobel commented Mar 1, 2022

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?

mkobel added a commit to qube-ag/asset-pipeline that referenced this issue Mar 7, 2022
This enables the same behaviour as in sass-asset-pipeline.
Added webjar test cases in bot sass asset-pipelines.

fixes bertramdev#297
mkobel added a commit to qube-ag/asset-pipeline that referenced this issue Mar 7, 2022
This enables the same behaviour as in sass-asset-pipeline.
Added webjar test cases in bot sass asset-pipelines.

fixes bertramdev#297
mkobel added a commit to qube-ag/asset-pipeline that referenced this issue Mar 7, 2022
This enables the same behaviour as in sass-asset-pipeline.
Added webjar test cases in bot sass asset-pipelines.

fixes bertramdev#297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant