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

@import with relative URIs need base URI to resolve against #270

Open
yagee-de opened this issue May 25, 2023 · 2 comments
Open

@import with relative URIs need base URI to resolve against #270

yagee-de opened this issue May 25, 2023 · 2 comments

Comments

@yagee-de
Copy link

I wrote a CustomImporter to retrieve a SASS file URL. It all works well. But there is no way to support paths starting with "../" in import statements, as I don't have any clue what the URL of the importing SASS file is at this point.

dart-sass-java should give a reference to the importing document, like in jsass: https://gitlab.com/jsass/jsass/-/blob/master/src/main/java/io/bit3/jsass/importer/Importer.java

@yagee-de
Copy link
Author

From sass.embedded_protocol.EmbeddedSass.InboundMessage.CompileRequest you can reconstruct this information and forward it to the Importer:

    private String getCompileSource(CompileRequest compileRequest) throws IOException {
        final CompileRequest.InputCase inputCase = compileRequest.getInputCase();
        try {
            if (inputCase == CompileRequest.InputCase.PATH) {
                return new File(compileRequest.getPath()).toURI().toURL().toString();
            }
            if (inputCase == CompileRequest.InputCase.STRING) {
                return compileRequest.getString().getUrl();
            }
        } catch (MalformedURLException mue) {
            throw new IOException(mue);
        }
        return null;
    }

@yagee-de yagee-de changed the title @import with '../*' cannot be resolved @import with relative URIs need base URI to resolve against May 26, 2023
@larsgrefer
Copy link
Owner

Can you provide a complete example which reproduces your problem?

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

No branches or pull requests

2 participants