Reviewed & tested by the community
Project:
Asset Injector
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Oct 2019 at 08:36 UTC
Updated:
9 Sep 2024 at 23:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
_renify_ commentedComment #3
slydevil commentedI have run into this issue as well. This is a conflict between the s3fs module and this module. The workaround is to disable preprocess on all of the asset injector assets.
I'll try to work on a patch if I get the time.
Comment #4
slydevil commentedMoving this to the asset injector project since I think it's an issue on that side.
Comment #5
pookmish commentedComment #6
slydevil commentedWhen working with the s3fs module absolute URL's for CSS and JS have a path like /s3fs-css/whatever.css or /s3fs-js/whatever.js which is then reverse proxied to the S3 bucket. This is done to prevent relative links to things in the CSS and JS from referencing the S3 bucket which would cause broken links. The reverse proxy makes relative links resolve to the site domain.
The AssetInjectorCss and AssetInjectorJs classes are both calling the filePathRelativeToDrupalRoot() method, which transforms an already internal URI (public://asset_injector/css/whatever.css or public://asset_injector/js/whatever.js) into an absolute URL and then chops off the protocol and domain. This is causing s3fs internal URI's to be transformed into the reverse proxy paths (/s3fs-css/whatever.css or /s3fs-js/whatever.js) that don't mean anything internally. I understand it was done this way to transform public://asset_injector/css/whatever.css to /sites/default/files/asset_injector/css/whatever.css, but it doesn't need to be done this way. Drupal knows how to handle internal URI's when aggregating CSS and JS.
So, this patch is essentially to allow Drupal to translate the URI's (public://asset_injector/css/whatever.css or public://asset_injector/js/whatever.js) to absolute URL's when it deems it necessary.
The function that I removed was added for #2869562: Deployment does not change asset files, so it will need to be confirmed that this still works. I checked the following scenarios with great success:
Comment #7
_renify_ commented@slydevil Thank you so much
Comment #8
pookmish commentedThanks for the patch. Sorry for the delay. #2869562: Deployment does not change asset files is still functioning correctly even with the patch. Which makes sense since this patch just adjusts the path string and not the actual functionality involved in building the asset.
Comment #10
pookmish commentedComment #12
geek-merlinUnfortunately this broke dev on a regular install, which my colleague had a hard time to track down and bisect to this commit (thanks a lot Andi!).
So reverted this.
> Drupal knows how to handle internal URI's when aggregating CSS and JS.
I did not dig into this issue yet, but this assumption from #6 is wrong, at least until #2735717: Stream wrapper reference in JS library causes error in _locale_parse_js_file() is fixed (if it ever will, which is not clear yet).
@slydevil I have no experience with s3fs, can you elaborate a bit more how s3fs plays with the rest of drupal? Maybe that way we can find a way to make that use case work without killing others.
Comment #13
geek-merlinComment #14
geek-merlinOK i investigated this a bit and the core issue indicates this only happens on multilingual sites and can be worked around by converting to drupal-root-relative paths starting with /. Which we did, but lacking root support in a too-broad way.
Comment #15
geek-merlinPatch flying in with a shoot at this.
Comment #16
pookmish commented@slydevil could you please review the patch from #15. If it works, we can look at getting this supported.
Comment #17
cracu commented@pookmish, it seems that #15 works with s3fs with/without css preprocessing.
Comment #18
bladeduRerolled patch #15 to work with 2.16.0
Comment #19
trackleft2#18 works for me. Thanks
Comment #20
hanoiiWhile maybe not exactly the same, I believe that #3454952: Support the new assets stream wrapper on Drupal 10.1.0+ should help with this on 10.1+, at least make it store it locally instead of s3fs which is what I would expect for dynamically generated assets.
Comment #21
trackleft2Rerolling for Asset Injector 8.x-2.21