diff --git a/Procfile b/Procfile new file mode 100644 index 00000000000..157e143cc20 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm run start:express diff --git a/package.json b/package.json index e9aba4805c4..3bfd98ba417 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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 lerna@2.0.0-beta.36", - "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", @@ -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" }, @@ -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", diff --git a/packages/terra-site/package.json b/packages/terra-site/package.json index f01a6fdba50..caef1ca05d1 100644 --- a/packages/terra-site/package.json +++ b/packages/terra-site/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/cerner/terra-core#readme", "scripts": { - "start": "webpack-dev-server --progress --port ${PORT:-8080}", + "start": "webpack-dev-server --progress", + "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", diff --git a/scripts/express/README.md b/scripts/express/README.md new file mode 100644 index 00000000000..afedfd7f4fe --- /dev/null +++ b/scripts/express/README.md @@ -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 diff --git a/scripts/express/app.js b/scripts/express/app.js new file mode 100644 index 00000000000..7e6c0516ab1 --- /dev/null +++ b/scripts/express/app.js @@ -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'}`);