vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.26k stars 2.14k forks source link

Inconsistent handling of env variable in dev and build #4222

Open Peque opened 2 months ago

Peque commented 2 months ago

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:

Development works as expected:

Builds do not work as expected when opening http-serve:

Expected behavior

Development works as expected:

Builds do not work as expected when opening http-serve:

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.