#Autoreload dev server when file ".env" is changed
24 messages · Page 1 of 1 (latest)
ConfigModule.forRoot({
isGlobal: true,
envFilePath: [`${process.cwd()}${process.env.NODE_ENV === 'production' ? '\\envs\\prod.env' : '\\envs\\local.env'}`]
}),
Something like that you can do with several envs, but Nest watch to .env on dev mode on default, read docs
https://docs.nestjs.com/techniques/configuration
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
I think I didn't make myself clear.
I want the development mode to autoreload the server whenever the .env file is changed.
Autoreload dev server when file ".env" is changed
With nodemon one can list every single file/directory to be watched.
I kind of wanted something like that.
that's usefull, i also want to use it, if it's exists
today i must refresh several times manually 🙂
https://www.reddit.com/r/Nestjs_framework/comments/ysry1a/how_to_make_nestjs_app_auto_reload_after_changing/
I found sth like that
Hot Reload module in Nest, but i don't have time now to try it, if u find something intresting, let my know, if u can 🙂
This is the Hot Reload of modules, without compiling all modules again.
Each module can me Hot Reloaded individually with Webpack.
I think the original problem would persist because .env is not part of any module.
maybe you can use nodemon in the same script in package.json as run start:dev
nest --watch
u know nest start --watch nodemon ...
u try that?
You mean to use nodemon as main process, encapsulating nest process?
And let only nodemon doing the watch thing?
ye, nodemon watching only env files
but wait
nodemon don't reload modules in that case i think
No, but it is, in theory, possible to make nodemon responsible to watch .env only, triggering a full reload of nest cli.
And let nest doing its own reload the way it is.
i think about it exacly
I won't try that now anyways.
I wanted a nest only solution 😆