Skip to content

Using local environment variables #118

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy