-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
inconsistencyInconsistency between dev & buildInconsistency between dev & buildp2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)
Description
Describe the bug
Static assets in CSS url() without opening slash / is not resolved or bundled with vite build.
For example, background-image: url('src/assets/sample.svg') will remain as is, without any file copied or path changed.
But background-image: url('/src/assets/sample.svg') will work correctly, with path changed to url('/assets/sample.svg') and file copied.
Both of the above are working correctly in dev mode.
I'm not sure if it's my problem or my responsibility to ensure the opening slash exists, but I can't find any related info in the doc or here. Sorry if I just missed something.
Reproduction
https://stackblitz.com/edit/vitejs-vite-2j2snf?file=src/App.css
System Info
System:
OS: macOS 12.5
CPU: (8) arm64 Apple M2
Memory: 3.17 GB / 24.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
npm: 8.18.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
Browsers:
Chrome: 104.0.5112.101
Firefox: 103.0
Safari: 15.6
npmPackages:
@vitejs/plugin-react: ^2.0.1 => 2.0.1
vite: ^3.0.9 => 3.0.9Used 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
inconsistencyInconsistency between dev & buildInconsistency between dev & buildp2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)