Skip to content

Using local environment variables #118

Closed
@azdanov

Description

@azdanov

Is there a way to specify environment variables for netlify.toml for local development?

As I understand this file is required during build stage on netlify and needs to be included inside the GitHub repository, for example. But this way it's impossible to hide any environment variables, such as API keys.

Are there any ways similar to create-react-app where .env.local is used, but ignored via .gitignore.

After messing around I found a workaround by specifying a webpack.functions.js that picks up .env:

const Dotenv = require('dotenv-webpack')

// @see https://github.com/netlify/netlify-lambda#webpack-configuration
module.exports = {
  plugins: [new Dotenv()],
}

If this is the best way, then it could be useful mentioning this approach in the readme.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions