S
SolidJS13mo ago
Mathieu

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
Mathieu13mo ago
yes it works when the files are in the specific workspace
mdynnl
mdynnl13mo 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
Mathieu13mo ago
ur a goddamn hero 🦸‍♂️ I put ../../. You see any issues?
mdynnl
mdynnl13mo ago
i; each workspaces' vite config, right?
Mathieu
Mathieu13mo ago
yes
export default defineConfig({
envDir: '../../',
export default defineConfig({
envDir: '../../',
in each workspace
mdynnl
mdynnl13mo ago
yeah, i think so, i wonder if you can extend configs
Mathieu
Mathieu13mo ago
!close /close hm