From 321f9ae75473ea2cd9906165ba26be1cc0d9b237 Mon Sep 17 00:00:00 2001 From: Ilya Surmay Date: Thu, 11 Jan 2018 18:10:59 +0200 Subject: [PATCH] fix(ci): fix heroku, deploy only demo/dist (#3441) --- .travis.yml | 2 ++ Procfile | 1 - package.json | 5 +++-- scripts/universal/configure-heroku.js | 5 +++++ scripts/universal/server.ts | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) delete mode 100644 Procfile create mode 100644 scripts/universal/configure-heroku.js diff --git a/.travis.yml b/.travis.yml index 58c5a2d7bc..a15bd21dbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -136,6 +136,8 @@ jobs: on: development - stage: deploy script: npm run build:dynamic + before_deploy: + - cd ./demo/dist deploy: provider: heroku api_key: $HEROKU_API_KEY diff --git a/Procfile b/Procfile deleted file mode 100644 index 628b8fab77..0000000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: node demo/dist/server.js diff --git a/package.json b/package.json index fac8a593c3..ef52733752 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,11 @@ "e2e-cross": "SAUCE=true npm run e2e", "e2e-bdd": "protractor ./protractor.cucumber.js", "view-stats": "webpack-bundle-analyzer demo/dist/stats.json", - "build:dynamic": "run-s build link build:client-and-server-bundles webpack:server", + "build:dynamic": "run-s build link build:client-and-server-bundles webpack:server configure-heroku", "serve:dynamic": "node demo/dist/server.js", "build:client-and-server-bundles": "ng build -bh / --prod --env=server && ng build -bh / --prod --env=server --app 1 --output-hashing=false", - "webpack:server": "webpack --config ./scripts/universal/webpack.server.config.js --progress --colors" + "webpack:server": "webpack --config ./scripts/universal/webpack.server.config.js --progress --colors", + "configure-heroku": "node scripts/universal/configure-heroku.js" }, "main": "bundles/ngx-bootstrap.umd.js", "module": "index.js", diff --git a/scripts/universal/configure-heroku.js b/scripts/universal/configure-heroku.js new file mode 100644 index 0000000000..f5773665a0 --- /dev/null +++ b/scripts/universal/configure-heroku.js @@ -0,0 +1,5 @@ +const fs = require('fs-extra'); +const path = require('path'); + +fs.writeFileSync(path.join(process.cwd(), 'demo/dist/Procfile'), 'web: node server.js', 'utf8'); +fs.writeFileSync(path.join(process.cwd(), 'demo/dist/package.json'), '{"name": "ngx-universal", "version": "1.0.0" }', 'utf8'); diff --git a/scripts/universal/server.ts b/scripts/universal/server.ts index ae1b549df3..a8ac7a382a 100644 --- a/scripts/universal/server.ts +++ b/scripts/universal/server.ts @@ -18,7 +18,7 @@ const app = express(); app.use(compression()); const PORT = process.env.PORT || 3000; -const DIST_FOLDER = join(process.cwd(), 'demo/dist'); +const DIST_FOLDER = join(process.cwd(), process.env.DYNO ? './' : 'demo/dist'); // Our index.html we'll use as our template const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();