Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

fix: support asset importing (ssr) #7

Closed
pi0 opened this issue Feb 25, 2021 · 13 comments · Fixed by #179
Closed

fix: support asset importing (ssr) #7

pi0 opened this issue Feb 25, 2021 · 13 comments · Fixed by #179
Labels
bug Something isn't working

Comments

@pi0
Copy link
Member

pi0 commented Feb 25, 2021

template:

<img src="../assets/logo.svg">
 ERROR  [vite]: Rollup failed to resolve import "assets/logo.svg" from "pages/index.vue?vue&type=template&lang.js".                                                                     22:44:25
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`


 ERROR  Server compiled with errors: [vite]: Rollup failed to resolve import "assets/logo.svg" from "pages/index.vue?vue&type=template&lang.js".                                        22:44:25
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
@pi0 pi0 added the bug Something isn't working label Feb 25, 2021
@aysnet1

This comment has been minimized.

@pi0 pi0 changed the title Importing with alias broken fix: support asset importing (ssr) Feb 27, 2021
@pi0
Copy link
Member Author

pi0 commented Feb 27, 2021

most of issues resolved with latest version of vite-plugin-vue. But URL generated by SSR is 404. (PR to track: #39)

@WebMBX
Copy link

WebMBX commented Mar 10, 2021

same error, still not working...

nuxt: 2.15.2
nuxt-vite: 0.0.28

<img src="logo.svg"/>

ERROR [vite]: Rollup failed to resolve import "logo.svg" from "components/Head.vue?vue&type=template&lang.js". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it tobuild.rollupOptions.external``

@jshimkoski
Copy link

Any status on this? I'd love to jump on the Vite train but the inability to use assets from the static directory is a showstopper.

I'm surprised the content module is marked as working with Vite as its assets are basically required to be served from the static directory.

@RobbieTheWagner
Copy link

Just ran into this as well. Any updates here?

@togetherwithasteria
Copy link

togetherwithasteria commented May 12, 2021

Same issue here, running on Nuxt Vite 0.0.37.

For workarounds, I guess using third-party CDN would work.

@productdevbook
Copy link
Member

CleanShot 2021-05-14 at 21 28 55
v1.0.0

@pi0
Copy link
Member Author

pi0 commented May 15, 2021

@productfrontenddeveloper Would you please make a reproduction or share index.vue?

@productdevbook
Copy link
Member

@productfrontenddeveloper Would you please make a reproduction or share index.vue?

index.vue.zip

@RobbieTheWagner
Copy link

@pi0 I see you merged a PR to disable SSR in development. Won't that introduce a lot of gotchas if the dev environment does not support SSR?

@pi0
Copy link
Member Author

pi0 commented May 20, 2021

Yes, you have to be careful about SSR compatibility during development. Due to issues like this and others mentioned in #139, disabling allows having a more stable experience of vite. Hopefully, we can turn SSR back to enabled soon :)

@productdevbook
Copy link
Member

when fixed :(

@ahmed56734
Copy link

import like this with @ <img src="@/assets/logo.svg">

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants