-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Describe the bug
In my project, I need to reference a static assets file outside the project root.
See code here:
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/importAnalysis.ts#L336
It seems that in ssr mode, vite will not prepend base to assets file url
However, code here:
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/importAnalysis.ts#L523
vite will replace base with ''. WHAT IF my project directory already contains base as part of path? In my project, it will replace it with ''.
For example, my project root directory is like /projects/subpath, setting base in vite.config.ts to '/subpath/', start vite in ssr mode and you will find all the assets reference url is normalized as @fs/projects/assets/xxx.svg rather than @fs/projects/subpath/assets/xxx.svg
Reproduction
https://github.com/uuau99999/vitejs-vite-ekqdje
System Info
System:
OS: macOS 12.4
CPU: (10) x64 Apple M1 Pro
Memory: 30.87 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.18.0 - ~/.nvm/versions/node/v14.18.0/bin/node
Yarn: 1.22.18 - ~/Library/pnpm/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.0/bin/npm
Browsers:
Chrome: 103.0.5060.53
Safari: 15.5
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- 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.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.