Skip to content

Instantly share code, notes, and snippets.

@joanvm
Last active December 14, 2018 07:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joanvm/f0119592679eadf07a59d75b7a81a577 to your computer and use it in GitHub Desktop.
Save joanvm/f0119592679eadf07a59d75b7a81a577 to your computer and use it in GitHub Desktop.

Adding environment variables

Setting a global variable

In webpack.*.js add webpack.DefinePlugin call with the process.env definition

plugins: [
	new webpack.HotModuleReplacementPlugin(),
	new webpack.NamedModulesPlugin(),
	new webpack.DefinePlugin({
		"process.env": {
			API_MOVIES_URL: '"http://localhost:3000"'
		}
	}),
  ]

Accessing a process environment

export const settings = {
	API_Movies_URL: process.env['API_MOVIES_URL'],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment