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

Remove an optimisation which breaks relative URLs #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shish
Copy link

@shish shish commented Aug 18, 2023

This optimisation disables relative paths when the output path is longer than the input path - but the result of that is that the generated CSS ends up pointing to URLs that are relative to the current directory instead of being relative to the generated CSS file.

input: test-in/style.css

.foo { background-image: url("./local.png"); }

When writing to an output directory which is less than or equal to the depth of the input, the path to the file is relative to the output .css

output: test-out/style.css

.foo { background-image: url("../test-in/local.png"); }

When writing to an output directory which is deeper than the input, relativity is disabled, and the path is broken

output: test-out/nested/path/style.css

.foo { background-image: url("test-in/local.png"); }

This optimisation disables relative paths when the output path is longer
than the input path - but the result of that is that the generated CSS
ends up pointing to URLs that are relative to the current directory
instead of being relative to the generated CSS file.

input: test-in/style.css
```
.foo { background-image: url("./local.png"); }
```

output: test-out/style.css
```
.foo { background-image: url("../test-in/local.png"); }
```

output: test-out/nested/path/style.css
```
.foo { background-image: url("test-in/local.png"); }
```
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 this pull request may close these issues.

1 participant