Giter Club home page Giter Club logo

Comments (7)

pflugs30 avatar pflugs30 commented on July 27, 2024 2

One comment about the basePath option. I configured my serverless.yml file to load from a folder containing all my env files, but the plugin consistently couldn't find them or resolve the environment names. I resolved the problem when I added a trailing '/' character to the property, like this:

  dotenv:
    basePath: env/

Note: I am developing on Windows 10 with Visual Studio Code. Perhaps other people may have different results on different platforms? Otherwise, perhaps this line should use some kind of environment specific path combine function?

from serverless-dotenv-plugin.

aldex32 avatar aldex32 commented on July 27, 2024 1

Nevermind, basePath is the way to go.

from serverless-dotenv-plugin.

zhaoyi0113 avatar zhaoyi0113 commented on July 27, 2024

Ok, I figured out how it works. When I specify path, it will ignore basePath configuration and name resolution. Is it true? If yes, I can't specify a different file name?

from serverless-dotenv-plugin.

snavarro89 avatar snavarro89 commented on July 27, 2024

Did you ever got this to work?

from serverless-dotenv-plugin.

neverendingqs avatar neverendingqs commented on July 27, 2024

Ok, I figured out how it works. When I specify path, it will ignore basePath configuration and name resolution. Is it true? If yes, I can't specify a different file name?

That is correct. If path is provided, basePath is ignored:

resolveEnvFileNames(env) {
if (this.config && this.config.path) {
if (Array.isArray(this.config.path)) {
return this.config.path
}
return [this.config.path]
}
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
const dotenvFiles = [
`.env.${env}.local`,
`.env.${env}`,
// Don't include `.env.local` for `test` environment
// since normally you expect tests to produce the same
// results for everyone
env !== 'test' && `.env.local`,
`.env`,
]
const basePath =
this.config && this.config.basePath ? this.config.basePath : ''
const filesNames = dotenvFiles.map((file) => basePath + file)
return filesNames.filter((fileName) => fs.existsSync(fileName))
}

From the README:

This will disable automatic env file resolution

Could you describe your use case more? Are you looking to load environment variables from both config/.env.joey and config/.env when you run sls deploy --stage joey?

from serverless-dotenv-plugin.

aldex32 avatar aldex32 commented on July 27, 2024

Hi @neverendingqs ,
As described in the documentation, when setting the property path it disables the automatic env file resolution. Why so? Can we still have the resolution even when using a different path? Or is this a limitation in the dotenv library?

from serverless-dotenv-plugin.

github-actions avatar github-actions commented on July 27, 2024

Closed due to inactivity. Please reopen when you get a chance to respond.

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.