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

Webpacker can't find subdir/image.png in manifest.json #44

Closed
honzasterba opened this issue Feb 2, 2022 · 8 comments · Fixed by #47
Closed

Webpacker can't find subdir/image.png in manifest.json #44

honzasterba opened this issue Feb 2, 2022 · 8 comments · Fixed by #47
Labels

Comments

@honzasterba
Copy link

Ruby version: 3.03
Rails version: 7.0.1
Webpacker version: 6.0.2 (same for js and gem)

Expected behavior:

  • put an image file into /app/javascript/images/subdir/image.png
  • use image_pack_tag "subdir/image.png" in view
  • image should be found by webpacker and rendered

Actual behavior:
Error is raised: Webpacker can't find subdir/image.png in .../manifest.json

Small, reproducible repo:
https://github.com/honzasterba/packer-test

@honzasterba honzasterba added the bug label Feb 2, 2022
@honzasterba
Copy link
Author

honzasterba commented Feb 2, 2022

first I thought I was doing something wrong, but this just seems like a big source of incompatibility between webpacker and shakapacker

webpack-asset-manifest says: will generate a JSON file that matches the original filename with the hashed version

so maybe thats it? instead of file-path->hashed-version it generates only file-name->hashed version?

there is a difference to how to manifest used to look like with webpack5:
"media/subdir/image.png": "/packs/media/images/subdir/image-HASH.png"

now with shakapacker:
"static/image.png": "/packs-test/static/image-bd51daf42131d4298622.png"

@tomdracz
Copy link
Collaborator

tomdracz commented Feb 2, 2022

Looks like this was open issue with rails/webpacker. For more see rails/webpacker#2956. Likely changed in rails/webpacker#2802 Need to dig into this and figure out what was the reason for this change.
It did trip me up when I was upgrading, referencing asset name without a folder seems to work but might cause some issues as outlined in the discussion at rails/webpacker above

@tomdracz
Copy link
Collaborator

tomdracz commented Feb 3, 2022

@honzasterba Can you try out the changes in #47 and see if that fixes the issue for you?

@honzasterba
Copy link
Author

will do!

@honzasterba
Copy link
Author

I have checked and I can verify that #47 fixes the issue

@tomdracz
Copy link
Collaborator

tomdracz commented Feb 3, 2022

Thanks! Need to give it few me spins but hopefully we can merge and release soon!

@justin808
Copy link
Member

Awesome work guys!

@justin808
Copy link
Member

I'll release 6.1.0 on Friday.

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

Successfully merging a pull request may close this issue.

3 participants