-
Notifications
You must be signed in to change notification settings - Fork 108
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
Images only loading from within entrypoints
directory
#97
Comments
Hi Jonic! The Troubleshooting guide is indeed misleading in this scenario, I will update it accordingly. To answer your question, all tag helpers including If you are only referencing images from any JS or CSS processed by Vite, you would be able to import them without placing them under |
Updated the docs, removed the reference to an unrelated older issue in Vite, and clarified where the assets are located in the Rails Thanks! |
@ElMassimo Thanks for the clarification - it's much clearer now! I was hoping to use Github's ViewComponent gem, keeping each component's assets with the Ruby class and
I understand that I'd have to import the Sass and JS from an entrypoint, and that these files can in turn load images, but would I be unable to reference the images with |
@Jonic If you are referring to Sidecar Assets, it should be possible to do something similar in Vite Ruby. Instead of Here's an example using If you are referencing individual assets from Rails views or partials directly, then it's not going to be a drop-in replacement, but if you are combining the components in a single "pack" it should be easier.
No. When using Vite.js you would ideally |
bundle update vite_ruby
.Packages
npm
"vite": "^2.4.1"
"vite-plugin-environment": "^1.0.1"
"vite-plugin-full-reload": "^0.2.2"
"vite-plugin-ruby": "^2.0.4"
Gems
vite_rails (2.0.12)
vite_ruby (1.2.15)
Description 📖
I've been trying to migrate a Rails Webpacker app to vite-rails, but I'm encountering a problem that appears to be a bug (possibly a regression), according to the troubleshooting guide.
My
app/frontend
directory matches that in the "entrypoints" section of the docs.I'm trying to use
vite_asset_path
to load an image kept inapp/frontend/images
, but is isn't loading, and it's not present in thepublic/vite/assets
directory. If I move the image to insideapp/frontend/entrypoints
, thenvite_asset_path
is able to load it.This is confusing because the troubleshooting guide specifically answers a question about images "only load[ing] if placed on entrypoints".
Adding to the confusion, one of the examples for
vite_asset_path
referencesimages/logo.svg
, without specifically mentioning where thisimages
directory exists, which gives the impression that this is the exampleimages
directory mentioned in the "entrypoints" section.Is this actually a bug, and loading from
app/frontend/images
should be possible? Or is it only the case thatvite_asset_path
will only be able to see anything kept inapp/frontend/entrypoints
?Whatever the case, I think the Rails tag helper docs and troubleshooting guide are confusing matters a little, and I would have also expected a warning or error upon passing a file into
vite_asset_path
that isn't found in the manifest.I've checked the example Rails app, which does keep its images in
app/frontend/entrypoints/images
, so after all this I can't figure out if I've read the docs incorrectly, or if something's missing from the docs, or if the docs are incorrect, or if all of this is actually a bug!Sorry for writing such a huge issue. Any help would be appreciated!
The text was updated successfully, but these errors were encountered: