You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const img = new URL('./logo.svg', import.meta.url);
export default img;
Vite prebuild the dependency into .vite/ folder, without moving asset into it.
Running dev mode, javascript file was loaded from .vite/ folder, static asset also loaded from .vite/, which is incorrect.
I should always configure optimizeDeps.exclude to prevent prebuild those assets, which is annoying.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
vite build works is because Deps optimization is enabled by default in dev only.
I can't explicitly import assets. Because I'm shipping an npm package with a lot of static asset. (eg, vue component with background image, map with on demand load geojson)
Describe the bug
I have a npm package with static asset using
new URL('img', import.meta.url)
to reference.npm package structure
index.js
Vite prebuild the dependency into
.vite/
folder, without moving asset into it.Running dev mode, javascript file was loaded from
.vite/
folder, static asset also loaded from.vite/
, which is incorrect.I should always configure
optimizeDeps.exclude
to prevent prebuild those assets, which is annoying.Reproduction
https://stackblitz.com/edit/vitejs-vite-sef4ob?file=main.js&terminal=dev
Steps to reproduce
vite build
&&vite preview
, you shoule see 2 vite logo works as expected.dev mode
preview mode
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: