Closed rctneil closed 3 years ago
@rctneil For me all images now work with -> static/
. So to access you can try out this path: static/neil-and-panda.webp
instead of images/neil-and-panda.webp
.
Hint: Check the manifest.json
file to see the paths.
@usmanchaudhryme Ok. Why do some files in the manifest have static pretended and others don't? It doesn't appear to be logical etc?
@usmanchaudhryme Why is the "static" prefix used anyway? There doesn't;t appear to be a mention of it anywhere in the docs or readme? Surely this is not right? What if I had two files in different subfolders with the same name?
I've solved this by adding/uncommenting these lines in app/packs/entrypoints/application.js
const images = require.context("../images", true);
const imagePath = (name) => images(name, true);
Then if you have an image at app/packs/images/logo.svg
you just need to use the helper <%= image_pack_tag 'logo.svg' %>
in the views.
This is an intentional change. Previously the prefix was media/images
in the pre
releases and got changed to static
in rc1. There is a reference to this in the changelog, but I agree that a blurb about it should be added to the README (or at the very least the v6 upgrade doc), because it seems like this has confused people (see #2859).
@guillaumebriday Suggest closing.
Hi,
My app is erroring with the following error:
The appropriate part of my view is:
My webpacker.yml file is:
I have webpack-dev-server running in the background.
I'd appreciate some guidance here as this has been bugging me for a while now.
Thanks, Neil