Skip to content

Commit c56dfd6

Browse files
author
gondzo
committed
load environment from .env file
1 parent c738143 commit c56dfd6

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

envSample renamed to .env.example

File renamed without changes.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ See Guild https://github.com/lorenwest/node-config/wiki/Configuration-Files
2323
|`REACT_APP_AUTH0_CLIEND_ID`| The React app auth0 client id`|
2424
|`REACT_APP_AUTH0_DOMAIN`| The React app auth0 domain`|
2525

26+
Environment variables will be loaded from the .env file during build. Create the .env file based on the provided env.example
2627

2728
## Install dependencies
2829
`npm i`

package.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
"lint": "eslint --ext jsx --ext js .",
1111
"lint:fix": "npm run lint -- --fix",
1212
"test": "mocha-webpack --require setup-test.js --webpack-config webpack.config-test.js \"src/**/*.spec.(jsx|js)\"",
13-
"postinstall":"npm run build",
14-
"heroku:prod:init":"git remote remove production && heroku create --remote production && heroku config:set NODE_ENV=production --remote production",
13+
"postinstall": "npm run build",
14+
"heroku:prod:init": "git remote remove production && heroku create --remote production && heroku config:set NODE_ENV=production --remote production",
1515
"heroku:dev:init": "git remote remove dev && heroku create --remote dev && heroku config:set NODE_ENV=development NPM_CONFIG_PRODUCTION=false --remote dev",
16-
"heroku:staging:init": "git remote remove staging && heroku create --remote staging && heroku config:set NODE_ENV=staging --remote staging",
16+
"heroku:staging:init": "git remote remove staging && heroku create --remote staging && heroku config:set NODE_ENV=staging --remote staging",
1717
"heroku:test:init": "git remote remove test && heroku create --remote test && heroku config:set NODE_ENV=test --remote test",
18-
"heroku:prod:deploy":"git push production master",
19-
"heroku:dev:deploy":"git push dev master",
20-
"heroku:staging:deploy":"git push staging master",
21-
"heroku:test:deploy":"git push test master"
18+
"heroku:prod:deploy": "git push production master",
19+
"heroku:dev:deploy": "git push dev master",
20+
"heroku:staging:deploy": "git push staging master",
21+
"heroku:test:deploy": "git push test master"
2222
},
2323
"author": "",
2424
"license": "MIT",
@@ -44,6 +44,8 @@
4444
"cross-env": "^3.1.2",
4545
"css-loader": "^0.23.0",
4646
"dateformat": "^2.0.0",
47+
"dotenv": "^2.0.0",
48+
"dotenv-webpack": "^1.3.1",
4749
"express": "^4.14.0",
4850
"extract-text-webpack-plugin": "^1.0.1",
4951
"file-loader": "^0.9.0",
@@ -65,17 +67,18 @@
6567
"rc-tooltip": "^3.4.2",
6668
"react": "^15.3.2",
6769
"react-breadcrumbs": "^1.5.1",
68-
"react-count-down": "^1.0.3",
6970
"react-click-outside": "^2.2.0",
71+
"react-count-down": "^1.0.3",
7072
"react-css-modules": "^3.7.10",
7173
"react-date-picker": "^5.3.28",
7274
"react-dom": "^15.3.2",
75+
"react-dropdown": "^1.2.0",
7376
"react-flexbox-grid": "^0.10.2",
7477
"react-google-maps": "^6.0.1",
75-
"react-dropdown": "^1.2.0",
78+
"react-highcharts": "^11.0.0",
7679
"react-icheck": "^0.3.6",
7780
"react-input-range": "^0.9.3",
78-
"react-highcharts": "^11.0.0",
81+
"react-modal": "^1.5.2",
7982
"react-redux": "^4.0.0",
8083
"react-redux-toastr": "^4.2.2",
8184
"react-router": "^2.8.1",
@@ -84,8 +87,8 @@
8487
"react-simple-dropdown": "^1.1.5",
8588
"react-slick": "^0.14.5",
8689
"react-star-rating-component": "^1.2.2",
87-
"react-timeago": "^3.1.3",
8890
"react-tabs": "^0.8.2",
91+
"react-timeago": "^3.1.3",
8992
"reactable": "^0.14.1",
9093
"redbox-react": "^1.2.10",
9194
"redux": "^3.0.0",
@@ -95,8 +98,8 @@
9598
"redux-logger": "^2.6.1",
9699
"redux-thunk": "^2.0.0",
97100
"sass-loader": "^4.0.0",
98-
"socket.io-client": "^1.7.1",
99101
"slick-carousel": "^1.6.0",
102+
"socket.io-client": "^1.7.1",
100103
"style-loader": "^0.13.0",
101104
"superagent": "^2.3.0",
102105
"superagent-promise": "^1.1.0",

webpack.config.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
const path = require('path');
44
const _ = require('lodash');
55
const webpack = require('webpack');
6+
const Dotenv = require('dotenv-webpack');
7+
68
const config = require('config');
79
const HtmlWebpackPlugin = require('html-webpack-plugin');
810
const ExtractTextPlugin = require('extract-text-webpack-plugin');
@@ -94,16 +96,12 @@ module.exports = {
9496
publicPath: '/',
9597
},
9698
plugins: [
99+
new Dotenv({
100+
path: '.env', // if not simply .env
101+
safe: true // lets load the .env.example file as well
102+
}),
97103
new webpack.DefinePlugin({
98-
__COVERAGE__: !argv.watch && process.env.NODE_ENV === 'test',
99-
'process.env': {
100-
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
101-
GOOGLE_API_KEY: JSON.stringify(process.env.GOOGLE_API_KEY),
102-
REACT_APP_API_BASE_PATH: JSON.stringify(process.env.REACT_APP_API_BASE_PATH),
103-
REACT_APP_SOCKET_URL: JSON.stringify(process.env.REACT_APP_SOCKET_URL),
104-
REACT_APP_AUTH0_CLIEND_ID: JSON.stringify(process.env.REACT_APP_AUTH0_CLIEND_ID),
105-
REACT_APP_AUTH0_DOMAIN: JSON.stringify(process.env.REACT_APP_AUTH0_DOMAIN),
106-
},
104+
__COVERAGE__: !argv.watch && process.env.NODE_ENV === 'test'
107105
}),
108106
new HtmlWebpackPlugin({
109107
GOOGLE_API_KEY: config.GOOGLE_API_KEY,

0 commit comments

Comments
 (0)
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