Describe the bug
When base: './' is set and the build is configured to emit CSS into a subfolder (via assetFileNames) while keeping images in a sibling folder,
Vite 8 writes url(./img/...) into the CSS instead of url(../img/...), which Vite 7 writes.
Reproduction
https://github.com/karlvr/vite-relative-base-bug
Steps to reproduce
npm install
npm run build:v8
Inspect ./dist/css/main-*.css and observe that the url to the background image is incorrect. It should be ../img/foo-*.png but it's ./img/foo-*.png.
You can compare with Vite 7 by running:
System Info
System:
OS: macOS 15.7.5
CPU: (10) arm64 Apple M1 Max
Memory: 119.17 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.15.0 - /Users/karlvr/.local/share/mise/installs/node/24/bin/node
npm: 11.12.1 - /Users/karlvr/.local/share/mise/installs/node/24/bin/npm
pnpm: 11.0.8 - /Users/karlvr/.local/share/mise/installs/node/24/bin/pnpm
Watchman: 2026.05.04.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 147.0.7727.138
Firefox: 59.0.3
Safari: 26.4
Used Package Manager
npm
Logs
No response
Validations
Describe the bug
When
base: './'is set and the build is configured to emit CSS into a subfolder (viaassetFileNames) while keeping images in a sibling folder,Vite 8 writes
url(./img/...)into the CSS instead ofurl(../img/...), which Vite 7 writes.Reproduction
https://github.com/karlvr/vite-relative-base-bug
Steps to reproduce
Inspect
./dist/css/main-*.cssand observe that the url to the background image is incorrect. It should be../img/foo-*.pngbut it's./img/foo-*.png.You can compare with Vite 7 by running:
System Info
System: OS: macOS 15.7.5 CPU: (10) arm64 Apple M1 Max Memory: 119.17 MB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.15.0 - /Users/karlvr/.local/share/mise/installs/node/24/bin/node npm: 11.12.1 - /Users/karlvr/.local/share/mise/installs/node/24/bin/npm pnpm: 11.0.8 - /Users/karlvr/.local/share/mise/installs/node/24/bin/pnpm Watchman: 2026.05.04.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 147.0.7727.138 Firefox: 59.0.3 Safari: 26.4Used Package Manager
npm
Logs
No response
Validations