Closed George3d6 closed 2 weeks ago
I may be a bit dense, but could you upload your reproduction into a github repo? The default create-tauri-app project also imports images from src/assets/ in the index.html
Hmh, in that case I expect I did something wrong, if you're saying "in the default app this should have been enough".
Asset importing from react ended up working if I specified the path & used the esm6 import syntax so I assume this is me messing with the config in a way that caused the import from index.html
to break (and might have to do with vite and not tauri itself)
So I will go ahead and close the issue
Describe the bug
Assets (in
src/assets
) behave in unusual where sometimes they work, for me, for example, when settings fonts:src: url(./assets/fonts/ESAllianz-Light.otf) format("opentype");
But not when setting the source of an image node, e.g.:
<img src="assets/icons/doc-icon.svg"></img>
Reproduction
Create the following
index.html
Then in
src/index.html
replace any scripts and have your body be:Result is
Expected behavior
I would expect files inside
src/assets
to behave consistently -- i.e. for the paths to work from anywhere, or at least to work from anywhere provided some function alaconvertFileSrc
is called to format the paths.Note: I am reasonably certain this is not a security.csp or security.assetProtocol issue (but those should be shipping /w sane defaults anyway) Note: I am also almost certain this is not a "bug" in that "some big brain way exists to modify 3 config files and call the 2 anointed holy functions in order to make this specific behavior work" -- However having sane defaults (e.g. files in assets get bundled and are accessible at consistent URLs) seems like a very relevant behavior -- so this might be better suited as "feature request" as opposed to "bug"
Full
tauri info
outputStack trace
No response
Additional context
No response