arabold / serverless-export-env

Serverless plugin to export environment variables into a .env file
MIT License
102 stars 34 forks source link

Add before:deploy hook #4

Closed hassankhan closed 6 years ago

hassankhan commented 7 years ago

Not sure if this is a supported or recommended use-case, but I'd like the .env exported from this package to be used by webpack-dotenv-plugin in my Webpack build.

Would you accept a PR for it? 😄

arabold commented 7 years ago

Hi @hassankhan. Interesting use case you have there. My only concern is that some of the environment variables are only know after deployment, e.g. all the AWS pseudo variables and references to CloudFormation resources using Fn::ImportValue will become available once the stack is finished creating, not before. So any environment resolved in the before:deploy hook would potentially be incomplete or invalid. Do you have some more details on what those environment variables used for Webpack would refer to?

hassankhan commented 7 years ago

Ahh you're correct, I meant after:deploy.

I wanted to use Webpack's NODE_ENV=production for production builds, but setting that manually resulted in only NODE_ENV being available (at least on local).

The idea was that this package would generate the env, then I guess re-deploy the functions :/