Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of env variable in dev and build #4222

Open
Peque opened this issue Sep 22, 2024 · 0 comments
Open

Inconsistent handling of env variable in dev and build #4222

Peque opened this issue Sep 22, 2024 · 0 comments
Labels
bug: pending triage Maybe a bug, waiting for confirmation stale

Comments

@Peque
Copy link

Peque commented Sep 22, 2024

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.
@Peque Peque added the bug: pending triage Maybe a bug, waiting for confirmation label Sep 22, 2024
@github-actions github-actions bot added the stale label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation stale
Projects
None yet
Development

No branches or pull requests

1 participant