-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add support for custom environment directory using Vite config #614
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
Merged
yamcodes
merged 22 commits into
yamcodes:main
from
danciudev:feat/support-custom-env-directory
Dec 30, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b5f7d10
feat: add support for custom environment directory using Vite config
Andrei-Danciu-Redslim d3f8bb5
Merge branch 'main' into feat/support-custom-env-directory
danciudev 02c8b0d
[autofix.ci] apply automated fixes
autofix-ci[bot] 4853027
test: add fixture tests for custom environment directory configuration
Andrei-Danciu-Redslim 59e5fa2
Merge branch 'main' into feat/support-custom-env-directory
danciudev 6fab7db
feat: add support for custom environment directory using Vite config
Andrei-Danciu-Redslim ccf7d80
[autofix.ci] apply automated fixes
autofix-ci[bot] 8db9e70
test: add fixture tests for custom environment directory configuration
Andrei-Danciu-Redslim 316c7d8
Merge branch 'feat/support-custom-env-directory' of https://github.co…
Andrei-Danciu-Redslim d933782
Merge branch 'main' into feat/support-custom-env-directory
yamcodes b23a89b
feat: test custom `envDir` usage by directly asserting `vite.loadEnv`…
yamcodes 5e338c0
test: verify `loadEnv` call with mode, envDir, and prefix
yamcodes 5462375
Remove `stubEnvVars` utility and its usage from tests, and delete the…
yamcodes e88bdbb
refactor: Update Vite plugin to use `.env` files for tests and improv…
yamcodes d195cb8
feat(vite-plugin): add support for Vite's `envDir` configuration option
yamcodes 9ae1b8e
test: add .env.test fixture files and configure test mode in Vite plu…
yamcodes 605c02f
test: Configure Vite build with `mode: "test"` and prioritize `.env.t…
yamcodes 0b3987f
refactor: update Vite plugin tests to spy on `arkenv`'s real implemen…
yamcodes 12a8ed4
test: remove unused `mockLoadEnv` declaration
yamcodes c3e7f43
feat: add .gitkeep to vite-plugin empty-dir fixture
yamcodes acb2210
test: replace mockReset with mockClear for mock cleanup in tests
yamcodes 9bf741b
feat: load and merge multiple .env files in tests with Vite's precede…
yamcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@arkenv/vite-plugin": patch | ||
| --- | ||
|
|
||
| #### Support Vite's `envDir` for custom env directories | ||
|
|
||
| The plugin now internally passes along [Vite's `envDir` config option](https://vite.dev/config/shared-options.html#envdir), allowing users to specify a custom directory for environment files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| VITE_API_URL=https://api.example.com | ||
| VITE_DEBUG=true |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { type } from "arkenv"; | ||
|
|
||
| export const Env = type({ | ||
| VITE_CUSTOM_VAR: "string", | ||
| VITE_FROM_ENV_DIR: "string", | ||
| }); |
3 changes: 3 additions & 0 deletions
3
packages/vite-plugin/src/__fixtures__/with-env-dir/custom-dir/.env.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| VITE_CUSTOM_VAR=custom-value | ||
| VITE_FROM_ENV_DIR=loaded-from-env-dir | ||
| EXTRA_VAR=extra-value |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Test file that imports environment variables from custom envDir | ||
| export const config = { | ||
| customVar: import.meta.env.VITE_CUSTOM_VAR || "", | ||
| fromEnvDir: import.meta.env.VITE_FROM_ENV_DIR || "", | ||
| }; |
1 change: 1 addition & 0 deletions
1
packages/vite-plugin/src/__fixtures__/with-env-dir/vite-env.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /// <reference types="vite/client" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.