Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Update to use express for heroku reviews app #326

Merged
merged 15 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm run start:express
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "0.1.0",
"description": "terra-core",
"engines": {
"node": "6.9.4"
},
"node": "6.9.4"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cerner/terra-core.git"
Expand Down Expand Up @@ -42,9 +42,10 @@
"clean:install": "npm run clean:all && npm install",
"clean:obsolete-snapshots": "npm test -- -u",
"compile": "lerna run compile",
"compile:heroku": "cd packages/terra-site && npm run compile:heroku",
"deploy": "lerna run --scope terra-site deploy",
"heroku-prebuild": "npm install -g [email protected]",
"heroku-postbuild": "npm install --only=dev",
"heroku-postbuild": "npm install --only=dev && npm run compile:heroku",
"jest": "jest",
"jest:coverage": "jest --coverage",
"lint": "npm run lint:js && npm run lint:scss",
Expand All @@ -54,6 +55,7 @@
"pretest": "npm run lint",
"postinstall": "npm run bootstrap",
"start": "cd packages/terra-site && npm run start",
"start:express": "node scripts/express/app.js",
"test": "npm run jest && npm run test:nightwatch-default",
"test:nightwatch-default": "node ./packages/terra-toolkit/lib/scripts/nightwatch-process.js --env default-tiny,default-small,default-medium,default-large,default-huge,default-enormous"
},
Expand All @@ -72,6 +74,7 @@
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"express": "^4.15.2",
"glob": "^7.1.1",
"husky": "^0.13.1",
"identity-obj-proxy": "^3.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/terra-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"homepage": "https://github.com/cerner/terra-core#readme",
"scripts": {
"start": "webpack-dev-server --progress --port ${PORT:-8080}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to lose the port argument? It does help for local development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $PORT setting's just used for Heroku deployment. I just roll it back after switching to express server.

If it's helpful, I'm fine with just keeping it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the post scrum sync, remove PORT for now. Firstly, currently, we have same PORT config. So we can't open webpack-dev-server and run the npm run test at the same time. We may have two different ports for those and also handle the hot reloading of webpack-dev-server.

Secondly, we can use command line to run dev server on any PORT. That will give developers more control on the command arguments.

"compile:heroku": "webpack --config webpack.prod.config --progress",
"compile:prod": "webpack --config webpack.prod.config -p",
"compile:prod-stats": "webpack --config webpack.prod.config -p --json > stats.json",
"deploy": "npm run compile:prod && gh-pages -d build",
Expand Down
11 changes: 11 additions & 0 deletions scripts/express/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#start:express

The start:express script will automatically run on Heroku reviews app pipeline or it can manually be executed using the command below:

```
npm run compile:heroku
npm run start:express
```

The start:express script will:
* Start an express server to serve all built static assets by webpack
15 changes: 15 additions & 0 deletions scripts/express/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-console */
const express = require('express');
const path = require('path');

const app = express();
const port = process.env.PORT || 8081;
// path to webpack built path
const buildPath = path.join(__dirname, '../../packages/terra-site/build');

app.use('/static', express.static(buildPath));
app.get('/', (req, res) => res.redirect('/static'));
app.listen(port);
console.log(`Listening ${port}`);
console.log(`Production Environment: ${process.env.NODE_ENV === 'production'}`);