sprockets-rails: 3.4.1: Relative assets urls are converted into absolute ones. Breaking existing code.
In https://github.com/rails/sprockets-rails/commit/05dbab27d54f58a7a505498863dd0d88a6b32389 a breaking change was introduced and released as 3.4.1 as a hotfix for the already breaking 3.4.0
Before sprockets 3.3.0 a url like url(img/thing.gif)
inside a folder loads the image from the current folder (the folder the file lives in) relatively. This is valid HTML/CSS and every css processor reads this correctly.
Now the url is converted into an absolute URL. This breaks a lot of existing frontend code. In a patch level release by the way.
Can we revert this please and release a new version? Then rethink changes made in 3.3.0 and 3.4.0 and release them as a 4.0 instead if a breaking change is intentional/necessary?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 31 (15 by maintainers)
Commits related to this issue
- Strip away the relative path (#482) Fixes #478 — committed to rails/sprockets-rails by jcoyne 3 years ago
- bug fix for css absolute path issue https://github.com/rails/sprockets-rails/issues/486 — committed to spree-wuboy/spree_scaffold by wuboy0307 2 years ago
The approach in #489 would work for us and fix the issue with us not being able to upgrade ☺️
As I asked above, can we bump the version to
4.0.0.pre
with the changes for Rails 7 and revert the breaking changes from 3.3, 3.4 and release them as 3.3.1 and 3.4.2?Then we can pin our projects to
sprockets-rails ["~> 3.3", "< 4.0"]
and Rails 7 can start using4.0.0pre
@rafaelfranca @dhh are you fine with that?
Option to turn off rewriting has been shipped in https://github.com/rails/sprockets-rails/releases/tag/v3.4.2.
In retrospect, yes, we probably should have bumped the major version. But that’s more of a stylistic change. The end result would have been the same: some use patterns would have been incompatible. I don’t see the trade off of reverting changes, pushing out a new 3.x release, then doing a separate 4.0 as being worth it at this point, though.
We can fix the relative-to-absolute conversion, though. So that the absolute path is translated relative to the path of the asset. @jcoyne, if you want to tackle that, please go ahead, and we can release that in 3.4.x.