nest-cli icon indicating copy to clipboard operation
nest-cli copied to clipboard

how to copy .env file in dist after automatic build

Open mdenoun opened this issue 7 years ago • 5 comments

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


mdenoun avatar Apr 01 '19 07:04 mdenoun

Honestly, I don't see any reason in copying .env file to dist directory. Anyway, please, use StackOverflow for such questions.

kamilmysliwiec avatar Apr 01 '19 07:04 kamilmysliwiec

@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. ;-)

thomrick avatar Apr 01 '19 08:04 thomrick

Thank you @ThomRick I tried your solution it solved my issue.

mdenoun avatar Apr 02 '19 12:04 mdenoun

@thomrick basically you saying that it is better using real env variables vs copying the .env file over, right?

kuncevic avatar Aug 01 '24 02:08 kuncevic

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

kamilmysliwiec avatar Aug 01 '24 06:08 kamilmysliwiec