Giter Club home page Giter Club logo

Comments (8)

colynb avatar colynb commented on July 27, 2024 4

from serverless-dotenv-plugin.

slavaguzenko-vicinity avatar slavaguzenko-vicinity commented on July 27, 2024

@colynb I think restoring hooks in the constructor should fix the problem:

// this.loadEnv()
this.hooks = {
  "before:offline:start:init": this.loadEnv.bind(this),
  "before:offline:start": this.loadEnv.bind(this),
  "before:invoke:local:invoke": this.loadEnv.bind(this),
  "before:deploy:resources": this.loadEnv.bind(this),
  "before:deploy:functions": this.loadEnv.bind(this),
  "before:package:initialize": this.loadEnv.bind(this),
}

from serverless-dotenv-plugin.

colynb avatar colynb commented on July 27, 2024

Hi @otbe - I've included an update to master branch with a new feature that I think resolves this issue. I have not published it to npm yet so if you wanted to try it out, just clone the repo. In a nutshell, you can control which env file is loaded based on what the environment is set to. You can set environment one of two ways: by setting NODE_ENV or passing in the --env option in the sls command. I've updated the README with more detailed instructions: https://github.com/infrontlabs/serverless-dotenv-plugin#automatic-env-file-name-resolution

from serverless-dotenv-plugin.

otbe avatar otbe commented on July 27, 2024

Hi @colynb

thanks for the update. 👍
Im not quite sure if this is a way I would like to go. We use many "stages" that are all build with NODE_ENV=production (configured by webpacks mode). So all artifacts are build in "production" mode and deployed with slightly different .env files for each stage. I dont know if there are any sideffects by setting NODE_ENV to something like "stage1" even if its set to "production" by webpack internally. 🤔

Any thoughts?

from serverless-dotenv-plugin.

colynb avatar colynb commented on July 27, 2024

from serverless-dotenv-plugin.

otbe avatar otbe commented on July 27, 2024

Oh 😱
Sorry I totally misinterpreted that part. Yes I think this should be fine for us :)

from serverless-dotenv-plugin.

colynb avatar colynb commented on July 27, 2024

from serverless-dotenv-plugin.

otbe avatar otbe commented on July 27, 2024

Dont know :/
At a first glance I thought --env is an alias to set NODE_ENV and I skipped the rest of the docs. But its mentioned quite well that --env should be used if you cant set NODE_ENV. So this should be fine 🤔

from serverless-dotenv-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.