dotenv-flow files can have names like: .env, .env.development, .env.development.local, ...
see: https://www.npmjs.com/package/dotenv-flow
I would like my node server to restart as soon as I update one of those files. However, adding a custom config, I am able to restart on a change in the .env file only.
"nodemonConfig": {
"watch": [".env"]
}
How could I watch files prefixed with .env ?
When overriding nodemon's watch
list you need to provide a full match list. For example, to watch js
files in the app
directory, .env
, and files prefixed with .env
e.g. .env.development
, you can use the following:
nodemon.json
{
"watch": ["app/*.js", ".env", ".env.*"]
}
The same concept works for dotenv-flow
dotenv-flow
"nodemonConfig": {
"watch": ["app/*.js", ".env", ".env.*"]
}
You'll likely need to modify the watch
list a bit more to suit your needs. All in all, that's the gist.