how to apply Env Vars to multiple npm scripts
xmlking opened this issue · 3 comments
xmlking commented
Recently I needed to run two scripts svelte-kit sync
& vite dev
and pass Env Vars
to second command.
This works
"scripts": {
"dev": "dotenv-run -v -f .env -f .secrets -- vite dev"
}
This didn't work. Env Vars
are not passed to vite dev
command
"scripts": {
"dev": "dotenv-run -v -f .env -f .secrets -- svelte-kit sync && vite dev"
}
any recommendations to accomplish this?
chihab commented
dotenv-run -v -f .env -f .secrets -- bash -c 'svelte-kit sync && vite dev'
?
or have a npm script:
"scripts": {
"dev:run": "svelte-kit sync && vite dev",
"dev": "dotenv-run -v -f .env -f .secrets -- npm run dev:run"
}
xmlking commented
Second one should work for both windows and Mac
b.t.w -f .env,.secrets
did not work on windows. Have to rewrite -f .env -f .secrets
chihab commented
I'll close the issue, let me know if you need any help.