Repository navigation
Labels
Description
Describe the bug
When I put a %%%TEMPLATE%%% in the base option in vite.config.js the build starts to fail. This was working before vite v5.4.0.
I'd expect to get a warning but the build still passes. Use case is I'd like to serve multiple versions of the same app with different base urls. The %%%TEMPLATE%%% is later replaced across files with my own script to create those multiple versions. I suppose this could be done with relative path, but should the build fail like that?
Reproduction
https://stackblitz.com/edit/vitejs-vite-jsfwq5kp?file=package.json
Steps to reproduce
Run npm install followed by npm run build
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vite: 5.4.0 => 5.4.0Used Package Manager
npm
Logs
Click to expand!
(!) "base" option should start with a slash.
error during build:
URIError: URI malformed
at decodeURI (<anonymous>)
at resolveConfig (file:///home/projects/vitejs-vite-jsfwq5kp/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:66263:18)
at async build (file:///home/projects/vitejs-vite-jsfwq5kp/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:65160:18)
at async CAC.eval (file:///home/projects/vitejs-vite-jsfwq5kp/node_modules/vite/dist/node/cli.js:843:5)eValidations
- 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.
Activity
sapphi-red commentedon Mar 10, 2025
Vite expects
baseto be a valid URL and%%%TEMPLATE%%%is not a valid URL. While Vite can probably handle those invalid URLs specially, I think the complexity is too much, given that you can easily workaround this by using a different character than%.