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

.env files from the parent directory are loaded #5712

Closed
7 tasks done
junaga opened this issue Nov 16, 2021 · 0 comments · Fixed by #6995
Closed
7 tasks done

.env files from the parent directory are loaded #5712

junaga opened this issue Nov 16, 2021 · 0 comments · Fixed by #6995

Comments

@junaga
Copy link
Contributor

junaga commented Nov 16, 2021

Describe the bug

When running the vite or vite build command in a package, in a monorepo, .env files from above the package, the vite project root, are loaded.

ty for your time vite is awesome

Reproduction

See the following example repo

git clone https://github.com/junaga/vite-env-bug
cd vite-env-bug/package/nested
npm install
npm run build

As you can see the .js chunk in dist/assets/ contains the variable from the .env file 2 directories above. The variable is not set in the build tool environment and still embedded into the final bundle, this is a huge security concern.

System Info

System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 8.91 GB / 12.43 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 14.18.1 - /usr/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 6.14.15 - /usr/bin/npm
  npmPackages:
    vite: ^2.6.4 => 2.6.14

Used Package Manager

npm

Logs

No response

Validations

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant