You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an nx monorepo, with several libs and apps. I want the .env.local file to be added to the cache hashes, so that all caches are invalidated when this file changes. The file is gitignored, so i can't just put its path in a sharedGlobal, seems like files inside of .gitignore are hard ignored by nx.
nx lint debug # this is a cache miss, as expected
nx lint debug # cache hit, as expected
echo "whatever" >> .env.local
nx lint debug # this should be a miss but it's a hit :(
which lead me to believe my approach was wrong, but inexplicably, when i use another file in the conf:
nx lint debug # this is a cache miss, as expected
nx lint debug # cache hit, as expected
echo "whatever" >> .env.local
nx lint debug # this should be a miss but it's a hit :(
switch to the ok branch
run the following commands sequence:
nx lint debug # this is a cache miss, as expected
nx lint debug # cache hit, as expected
echo "whatever" >> file.txt
nx lint debug # cache miss!
There's a way to make this work for your scenario, but while I was testing it, I found an issue 😅
Anyway, once the linked PR is merged, you'll be able to properly use the .nxignore file. Adding !.env.local to that file will whitelist it, and it will be included in hashes. So then in your sharedGlobals named input, you can have this instead:
"sharedGlobals": ["{workspaceRoot}/.env.local"]
Usually folks ignored whole folders, while nxignoreing subfolders, so the logic worked well there. With this scenario, we ignored and whitelisted the same file, so things got weird.
Current Behavior
I have an nx monorepo, with several libs and apps. I want the
.env.local
file to be added to the cache hashes, so that all caches are invalidated when this file changes. The file is gitignored, so i can't just put its path in a sharedGlobal, seems like files inside of .gitignore are hard ignored by nx.So, i use the following conf as a workaround:
which does not work. ie:
which lead me to believe my approach was wrong, but inexplicably, when i use another file in the conf:
Expected Behavior
I'm expecting the cache to behave the same way for both files
GitHub Repo
https://github.com/martin-mindflow/nx-cache-reproduction
Steps to Reproduce
ok
branchNx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: