Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import assets from encodeURI in production mode #6195

Closed
7 tasks done
yArna opened this issue Dec 20, 2021 · 1 comment · Fixed by #6199 or #6212
Closed
7 tasks done

Cannot import assets from encodeURI in production mode #6195

yArna opened this issue Dec 20, 2021 · 1 comment · Fixed by #6199 or #6212

Comments

@yArna
Copy link
Contributor

yArna commented Dec 20, 2021

Describe the bug

When the assets address in the source file is an encodeURI, it cannot be imported in build mode, but it works fine in dev mode

If there are spaces in the asset path you have to encodeURI for the address

// src
<img src="/%E4%B8%AD%E6%96%87/%E5%9B%BE%E7%89%87.png" srcset="/%E4%B8%AD%E6%96%87/%E5%9B%BE%E7%89%87.png 2x" alt="" />

// Expected results : 
<img src="/assets/图片.74dcfa9c.png" srcset="/assets/图片.74dcfa9c.png 2x" alt="" />

// Current results: 
<img src="/%E4%B8%AD%E6%96%87/%E5%9B%BE%E7%89%87.png" srcset="/%E4%B8%AD%E6%96%87/%E5%9B%BE%E7%89%87.png 2x" alt="" />

Reproduction

https://github.com/yArna/temp-vite-error-repo-unicode

System Info

System:
    OS: macOS 11.6.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Memory: 32.56 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 7.6.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Chrome Canary: 99.0.4777.0
    Firefox: 93.0
    Safari: 15.1

Used Package Manager

npm

Logs

No response

Validations

@yArna
Copy link
Contributor Author

yArna commented Dec 21, 2021

I found that HMR also has this problem

https://github.com/vitejs/vite/blob/main/packages/vite/src/client/client.ts

@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant