-
Notifications
You must be signed in to change notification settings - Fork 1.5k
resolved_paths
seems not working for images
#1887
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
Comments
Hi, I can help with your issue, I think you are doing it wrong, First, I think you should leave your resolved_paths as the default like so: |
I'll try to clone and run your application. Please hold on. |
Just clone it and |
Okay so I found a fix to the problem. |
|
@mayordwells Thanks for the tip! But I'm still not quite sure it's by design, it's no problem in Webpacker 3... Could you check this @gauravtiwari ? |
I will keep this open until we make a new release. |
Try new release, please 👍 |
Thank you! I'll try it now |
@gauravtiwari after updated to latest release, I found {
"application.js": "/packs/js/application-3dc1d2f93ffe63b255a8.js",
"application.js.map": "/packs/js/application-3dc1d2f93ffe63b255a8.js.map",
"entrypoints": {
"application": {
"js": [
"/packs/js/application-3dc1d2f93ffe63b255a8.js"
],
"js.map": [
"/packs/js/application-3dc1d2f93ffe63b255a8.js.map"
]
}
},
"media/avatar.png": "/packs/media/avatar-057862c7.png"
} |
Yes, all images or other static assets would now be written in the media folder. |
Might have to update README, where needed. |
@gauravtiwari Got it, Thank you! One more question:
|
does the media can be configured?
packs/images/avatar.png also will be media/avatar.png right?
if I have both assets/images/avatar.png and packs/images/avatar.png what behavior is correct?
|
Does this mean you can't have nested assets with the same name without reverting to the previous functionality? Trite example, but if I have From a quick test it looks like both files will actually be copied to public during compilation (with different hashes suffixed) but only one will be referenced in |
Hi there, I am having the same issue with this message
I followed the steps on the docs/v4-upgrade.md to upgrade from 3.5.5 to latest today, and after a bit of fiddling around with babel stuff, I got my ./bin/webpack-dev-serverto compile with no errors. My images are all in app/javascript/images. The compiled images are there in the new media folder as explained above, but I cant seem to fix this issue, any thoughts? |
I guess I found a solution here: https://github.com/rails/webpacker/blob/master/CHANGELOG.md#400rc6---2019-01-25 Then I found this other solution here: I chose to leave the second one as a fix, but although I got it working now, I am still curious as to why I could not make it work in the new way. Thoughts? |
I'm trying Webpacker 4 & Rails 6 (both on master branch)
I set
resolved_paths: ['app/assets']
inwebpacker.yml
and put an imageapp/assets/images/avatar.png
In
app/javascript/packs/application.js
I addingimport "images/avatar.png"
in Rails view
<%= image_pack_tag 'images/avatar.png', alt: 'My avatar' %>
Then I start Rails and browse the page, I got
Webpacker::Manifest::MissingEntryError in Home#index
I think
"_/assets/images/avatar.png": "/packs/_/assets/images/avatar-057862c747f0fdbeae506bdd0516cad1.png"
look strange.If I move
app/assets/images/avatar.png
toapp/javascript/images/avatar.png
, it would be OK.But I do another experiment that I have
app/assets/stylesheets/application.scss
In
app/javascript/packs/application.js
I addingimport 'stylesheets/application'
In Rails view
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
No problem here.
The text was updated successfully, but these errors were encountered: