vite icon indicating copy to clipboard operation
vite copied to clipboard

[vite3] - image path in xx-legacy.[hash].js is __VITE_ASSET_[hash]__

Open GitYiM opened this issue 1 year ago • 0 comments

Describe the bug

I am having this issue in my app since upgrading to Vite 3. After build, I found that image path in xx-legacy.[hash].js is VITE_ASSET[hash]_ and I couldn't load the image when the browser downgrade to use legacy resources.

example:

  • before build <style scoped> .container { background-image: url("@/assets/test.jpeg"); } </style>
  • after build, path in xx-legacy.[hash].js .container[data-v-0bd88030]{background-image:url(__VITE_ASSET__e95e86d6__)}

Reproduction

https://github.com/GitYiM/legacy-assets-in-vite

System Info

System:
    OS: macOS 11.4
    CPU: 2.6 GHz Intel Core i7
    Memory: 173.15 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: v16.4.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.18.1 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Safari: 15.5

Used Package Manager

yarn

Logs

yarn run v1.22.10 $ vue-tsc --noEmit && vite build (!) "base" option should end with a slash. vite v3.0.2 building for production... ✓ 18 modules transformed. dist/static/js/index-legacy-af5f973d.js 53.60 KiB / gzip: 21.26 KiB dist/static/js/index-legacy-af5f973d.js.map 558.82 KiB dist/static/js/polyfills-legacy-02c9d353.js 59.34 KiB / gzip: 24.47 KiB dist/static/svg/vue-5532db34.svg 0.48 KiB dist/static/jpeg/test-e95e86d6.jpeg 219.88 KiB dist/index.html 1.78 KiB dist/static/css/index-e69c1395.css 1.37 KiB / gzip: 0.71 KiB dist/static/js/index-7cd36d41.js 53.11 KiB / gzip: 21.44 KiB dist/static/js/index-7cd36d41.js.map 540.43 KiB ✨ Done in 11.63s.

Validations

GitYiM avatar Jul 20 '22 08:07 GitYiM