Open
Description
Describe the bug
When using an env variable VITE_COLOR
to change the color of a theme importing a different CSS file depending on that variable, the behavior seem to be correct during development, but not after build.
Reproduction
Minimal reproducible example:
https://github.com/Peque/vitepress-color-change
The repository has two commits:
- First commit is just a basic Vitepress template.
- Second commit introduces the code to use different colors depending on the
VITE_COLOR
variable.
Development works as expected:
- ✅
VITE_COLOR=red npm run docs:dev
-> Red color - ✅
VITE_COLOR=blue npm run docs:dev
-> Blue color
Builds do not work as expected when opening http-serve
:
- ✅
VITE_COLOR=red npm run docs:build
-> Red color - ❌
VITE_COLOR=blue npm run docs:build
-> Red color
Expected behavior
Development works as expected:
- ✅
VITE_COLOR=red npm run docs:dev
-> Red color - ✅
VITE_COLOR=blue npm run docs:dev
-> Blue color
Builds do not work as expected when opening http-serve
:
- ✅
VITE_COLOR=red npm run docs:build
-> Red color - ✅
VITE_COLOR=blue npm run docs:build
-> Blue color
System Info
System:
OS: Linux 6.10 Fedora Linux 39 (Container Image)
CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Memory: 9.52 GB / 15.54 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
npmPackages:
vitepress: ^1.3.4 => 1.3.4
### Additional context
_No response_
### Validations
- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.