-
-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the problem
when using <img src="./foo.jpg">
in svelte component template, the image has to be put in publicDir and isn't hashed by vites asset pipeline.
see this discussion in svelte discord: https://discord.com/channels/457912077277855764/819723698415599626/868424304042319892
Describe the proposed solution
build a preprocessor to do the following:
- extract possible asset urls
- filter extracted with vites
asset_include
- rewrite url
a) figure out vite hash of the asset and put hashed url in src
b) addimport x from "<url>"
and rewrite src to<img src={x}>
( see https://github.com/bluwy/svelte-preprocess-import-assets)
add an option to inject that preprocessor within vite-plugin-svelte (like the others it's already doing)
Note: 3b would have the advantage that we don't need to figure out asset hashes as vite is going to rewrite the import down the road.
Alternatives considered
- could be implemented as a separate vite plugin with
api.sveltePreprocess
aswell 🤔 - direct people to use https://github.com/bluwy/svelte-preprocess-import-assets
Importance
nice to have
Additional Considerations (see Discussion)
- Interoperability with vite-plugins like vite-plugin-image and svelte-preprocessors
- Configurability (ability to include/exclude assets from being processed)
callmeberzerker
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request