Set environment variable for build in Netlify

后端 未结 6 1121
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 05:52

I\'m trying to set an environment variable for an API key that I don\'t want in my code. My source javascript looks something like this :

.get(`http://api-ur         


        
6条回答
  •  不知归路
    2020-12-03 06:28

    You can set Dotenv-webpack to load system environment variables as well as those you have declared in your .env file by doing the following:

      plugins: [
        new Dotenv({
            systemvars: true
        })
      ]
    

    I.e Setting the systemvars attribute of your webpack dotenv plugin to true.

    Note that system environment variables with the same name will overwrite those defined in your .env file.

    Source: https://www.npmjs.com/package/dotenv-webpack#properties

提交回复
热议问题