Skip to content

Images in /public folder in Rails app? #350

Answered by ElMassimo
themire asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Julian!

I think you are running into Vue's Asset URL Handling.

As a result, it's extracting the src as an import, which Rollup can't find in that path, triggering that error.


Note that only attribute values that are static strings are transformed

If you want to keep those images in public, making the src dynamic should prevent Vue from extracting it as an ESM import:

<img :src="`/images/photo.jpg`">

Otherwise, moving those images into <sourceCodeDir>/images and using a path such as @/images/photo.jpg should work, with Vue extracting that to import imageSrc from '@/images/photo.jpg' and Rollup fingerprinting that asset as for any URL import.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@themire
Comment options

@ElMassimo
Comment options

Answer selected by themire
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants