From 9d3c72e4d1044423d147541748f489a7c6d0cbb3 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 27 Jun 2018 14:53:09 -0500 Subject: [PATCH] Improvements to builds --- package.json | 4 ++-- script/build.sh | 18 ++++++++++++++++++ script/compile-assets.sh | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 script/build.sh diff --git a/package.json b/package.json index 226b9a45..538d7896 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "url": "https://github.com/houdiniproject/houdini" }, "scripts": { - "watch": "npm run export-button-config && npm run export-i18n && npm run generate-api-js && npx webpack --watch", - "build": "npm run export-button-config && npm run export-i18n && npm run generate-api-js && NODE_ENV=production npx webpack -p", + "watch": "HOUDINI_WATCH=1 script/build.sh", + "build": "script/build.sh", "build-all": "script/compile-assets.sh && npm run build", "test": "rake spec && npm run build && npx jest", "export-button-config": "bundle exec rake settings:generate_json", diff --git a/script/build.sh b/script/build.sh new file mode 100755 index 00000000..4bf03207 --- /dev/null +++ b/script/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + + +( +echo $HOUDINI_WATCH +set -e +set -o pipefail +export DATABASE_URL=${BUILD_DATABASE_URL:-postgres://admin:password@db/commitchange_development} +echo $DATABASE_URL +npm run export-button-config && npm run export-i18n && npm run generate-api-js + +if [ -z "$HOUDINI_WATCH"} ]; +then + npx webpack --watch +else + NODE_ENV=production npx webpack -p +fi +) \ No newline at end of file diff --git a/script/compile-assets.sh b/script/compile-assets.sh index cb31b083..aebfe137 100755 --- a/script/compile-assets.sh +++ b/script/compile-assets.sh @@ -1,2 +1,2 @@ #!/bin/bash -(source .env; RAILS_ENV=production bundle exec rake assets:precompile) +( RAILS_ENV=${RAILS_ENV:-production} DATABASE_URL=${BUILD_DATABASE_URL:-postgres://admin:password@db/commitchange_development} bundle exec rake assets:precompile )