Skip to content

Commit

Permalink
Use dotenv in webpack build
Browse files Browse the repository at this point in the history
Replace instances of process.env in the webpack bundle using
build-time environment variables. Environment variables can be
specified in a .env file.

The text replacement is performed by the `dotenv-webpack` package, a
wrapper for `dotenv` and `Webpack.DefinePlugin`.

SECURITY IMPLICATIONS

Do not reference any environment variables that contain sensitive
information. `dotenv-webpack` will expose all environment variables
that are explicitly referenced in client code.

We currently reference API_USER and API_PASSWORD in client code. When
login is implemented these environment variables should be removed,
and the password should be reset.
  • Loading branch information
cjolowicz committed Jan 2, 2019
1 parent ef00648 commit e55928e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import path from 'path';
import Dotenv from 'dotenv-webpack';

import {
PRODUCTION,
Expand Down Expand Up @@ -27,6 +28,9 @@ export default {
},
],
},
plugins: [
new Dotenv(),
],
devtool: PRODUCTION ? 'source-map' : 'eval',
resolve: {
extensions: ['.js'],
Expand Down

0 comments on commit e55928e

Please sign in to comment.