Skip to content

Commit 4a802d4

Browse files
author
gondzo
committed
Merge branch 'dev'
2 parents d391c6a + ae70bee commit 4a802d4

File tree

9 files changed

+84
-5
lines changed

9 files changed

+84
-5
lines changed

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: npm run start

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,24 @@ See Guild https://github.com/lorenwest/node-config/wiki/Configuration-Files
3434
|`lint:fix`|Lint and fix all `.js` files. [Read more on this](http://eslint.org/docs/user-guide/command-line-interface.html#fix).|
3535
|`test`|Run tests using [mocha-webpack](https://github.com/webpack/mocha-loader) for all `*.spec.(js|jsx)` files in the `src` dir.|
3636

37+
## Local deploy
38+
NODE_ENV=production npm run build
39+
NODE_ENV=production npm run start
40+
41+
## Heroku deploy
42+
43+
### Prerequisites
44+
- Heroku CLI
45+
46+
### set up
47+
npm run heroku:[ENV]:init
48+
npm run heroku:[ENV]:deploy
49+
50+
### update
51+
npm run heroku:[ENV]:deploy
52+
53+
`npm run heroku:[ENV]:init` will create a new git remote in current git repository and a new app in remote server.
54+
55+
`npm run heroku:[ENV]:deploy` line will push current branch to corresponding remote environment.
56+
57+
`ENV` can be 'prod', 'dev', 'staging', 'test'.

config/development.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable import/no-commonjs */
2+
/**
3+
* Main config file
4+
*/
5+
module.exports = {
6+
// below env variables are NOT visible in frontend
7+
PORT: process.env.PORT || 3000,
8+
9+
// below env variables are visible in frontend
10+
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY || 'AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI',
11+
API_BASE_PATH: process.env.API_BASE_PATH || 'https://kb-dsp-server-dev.herokuapp.com',
12+
};

config/production.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable import/no-commonjs */
2+
/**
3+
* config file for production environment
4+
*/
5+
module.exports = {
6+
// below env variables are NOT visible in frontend
7+
PORT: process.env.PORT || 3000,
8+
9+
// below env variables are visible in frontend
10+
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY || 'AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI',
11+
API_BASE_PATH: process.env.API_BASE_PATH || 'https://kb-dsp-server-dev.herokuapp.com',
12+
};

config/staging.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable import/no-commonjs */
2+
/**
3+
* Main config file
4+
*/
5+
module.exports = {
6+
// below env variables are NOT visible in frontend
7+
PORT: process.env.PORT || 3000,
8+
9+
// below env variables are visible in frontend
10+
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY || 'AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI',
11+
API_BASE_PATH: process.env.API_BASE_PATH || 'https://kb-dsp-server-dev.herokuapp.com',
12+
};

config/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable import/no-commonjs */
2+
/**
3+
* Main config file
4+
*/
5+
module.exports = {
6+
// below env variables are NOT visible in frontend
7+
PORT: process.env.PORT || 3000,
8+
9+
// below env variables are visible in frontend
10+
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY || 'AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI',
11+
API_BASE_PATH: process.env.API_BASE_PATH || 'https://kb-dsp-server-dev.herokuapp.com',
12+
};

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
"main": "index.js",
66
"scripts": {
77
"dev": "cross-env NODE_ENV=development nodemon server",
8-
"start": "cross-env NODE_ENV=production node server",
9-
"build": "cross-env NODE_ENV=production webpack --bail --progress --build --tc",
8+
"start": "node --max-old-space-size=512 server",
9+
"build": "node --max-old-space-size=512 ./node_modules/webpack/bin/webpack --bail --progress --build --tc",
1010
"lint": "eslint --ext jsx --ext js .",
1111
"lint:fix": "npm run lint -- --fix",
12-
"test": "mocha-webpack --require setup-test.js --webpack-config webpack.config-test.js \"src/**/*.spec.(jsx|js)\""
12+
"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",
15+
"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",
17+
"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"
1322
},
1423
"author": "",
1524
"license": "MIT",

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ if (process.env.NODE_ENV === 'development') {
4040
}
4141
const port = config.PORT;
4242
app.listen(port);
43-
console.log(`Server is now running at http://localhost:${port}.`); // eslint-disable-line no-console
43+
console.log(`Server is now running on port: ${port}.`); // eslint-disable-line no-console

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module.exports = {
9292
output: {
9393
filename: '[name].[hash].js',
9494
path: path.join(__dirname, './dist'),
95-
publicPath: __DEV__ ? `http://${ip.address()}:${process.env.PORT || 3000}/` : '/',
95+
publicPath: '/',
9696
},
9797
plugins: [
9898
new webpack.DefinePlugin({

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