How to share .env files among NPM Workspaces?

.env files are read from a workspace root folder (e.g. /packages/foo-app/.env), but the .env files are not read from the root of the npm workspaces. This leads me to duplicate the .env files for every workspace, or to have some hacky copy script. How can I have just one set of .env files for all workspaces?
8 Replies
Mathieu
MathieuOP2y ago
yes it works when the files are in the specific workspace
mdynnl
mdynnl2y ago
https://vitejs.dev/config/shared-options.html#envdir i meant to paste this recursive loading might impose security risks, but yeah, it's probably fine if we stop at root workspaces
Mathieu
MathieuOP2y ago
ur a goddamn hero 🦸‍♂️ I put ../../. You see any issues?
mdynnl
mdynnl2y ago
i; each workspaces' vite config, right?
Mathieu
MathieuOP2y ago
yes
export default defineConfig({
envDir: '../../',
export default defineConfig({
envDir: '../../',
in each workspace
mdynnl
mdynnl2y ago
yeah, i think so, i wonder if you can extend configs
Mathieu
MathieuOP2y ago
!close /close hm
Want results from more Discord servers?
Add your server