-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add a project-local
.envrc
file.
This fixes the issue described here: #547 (comment) It does so by configuring `direnv` to write its cache for this project in `~/.cache/direnv/layouts`. This is a bit intrusive, but without this workaround, `vite` commands search the local `.direnv` cache for dependencies, and it adds about 10 seconds or more to every `vite` command. Note that the fix comes from here: https://github.com/direnv/direnv/wiki/Customizing-cache-location Before falling back to this workaround, I also tried the following Vite configuration tricks, but none of them worked: https://vitejs.dev/config/server-options.html#server-watch https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude There are multiple (somewhat) related issues currently filed on Vite which suggest that convincing Vite not to look everywhere in the project root directory is a known issue: https://github.com/vitejs/vite/pull/8778/files vitejs/vite#7363 vitejs/vite#8341
- Loading branch information
Showing
3 changed files
with
14 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,13 @@ | ||
# Prevent direnv from creating a local .direnv cache. Otherwise, 'vite' | ||
# commands will be incredibly slow to start. | ||
|
||
: ${XDG_CACHE_HOME:=$HOME/.cache} | ||
declare -A direnv_layout_dirs | ||
direnv_layout_dir() { | ||
echo "${direnv_layout_dirs[$PWD]:=$( | ||
local path="${PWD//[^a-zA-Z0-9]/-}" | ||
echo "$XDG_CACHE_HOME/direnv/layouts/${path:1}" | ||
)}" | ||
} | ||
|
||
use flake |
This file contains 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 |
---|---|---|
|
@@ -13,7 +13,6 @@ result* | |
|
||
# direnv. | ||
.direnv/ | ||
.envrc | ||
|
||
# tsc | ||
tsconfig.tsbuildinfo | ||
|
This file contains 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