how to copy .env file in dist after automatic build
Documentation is lacking for cli. The documentation recommend to create .env file for configuration but does not say how to copy it automatically in dist folder during build?? any recommendation. In angular we can define our assets to be copied during build. Is there similar capability in nest. Thank you For Helping
I'm submitting a...
[ ] Regression
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Expected behavior
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment
Honestly, I don't see any reason in copying .env file to dist directory. Anyway, please, use StackOverflow for such questions.
@mdenoun you can update your package.json build script if you want to perform the copy operation. To add some practical details to @kamilmysliwiec I think the configuration files must be provided directly on your compute instance and not in your build artifact. A better use should be with environment variables and not configuration files. ;-)
Thank you @ThomRick I tried your solution it solved my issue.
@thomrick basically you saying that it is better using real env variables vs copying the .env file over, right?
Yes, you should be using real env variables in production instead of .env files. For those who still need .env file (for, for instance, less sensitive variables), you can use "assets" feature of Nest CLI https://docs.nestjs.com/cli/monorepo#assets