Add heroku release step

pull/1104/head
Rick Carlino 2019-02-05 09:10:06 -06:00
parent e7592081d4
commit 0f5dd7aa69
3 changed files with 38 additions and 23 deletions

View File

@ -1,3 +1,4 @@
worker: bundle exec rake jobs:work
rabbit_workers: bin/rails r lib/rabbit_workers.rb
web: bundle exec passenger start -p $PORT -e $RAILS_ENV --max-pool-size 2
release: bundle exec rake api:build_assets

View File

@ -25,6 +25,25 @@ class DashboardController < ApplicationController
acc
end)
PARCEL_ASSET_LIST = (CSS_INPUTS.values + JS_INPUTS.values)
.sort
.uniq
.map { |x| "frontend" + x }
.join(" ")
PARCEL_HMR_OPTS = [
"--hmr-hostname #{ENV.fetch("API_HOST")}",
"--hmr-port 3808"
].join(" ")
PARCEL_CLI_OUTRO = [
# WHY ARE SOURCE MAPS DISABLED?
# https://github.com/parcel-bundler/parcel/issues/2599#issuecomment-459131481
# https://github.com/parcel-bundler/parcel/issues/2607
# TODO: Upgrade parcel when issue ^ is fixed.
"--no-source-maps",
].join(" ")
[:main_app, :front_page, :password_reset, :tos_update].map do |actn|
define_method(actn) do
begin

View File

@ -50,32 +50,27 @@ namespace :api do
sh "sudo docker-compose up --scale parcel=0"
end
def parcel(cmd, opts = " ")
intro = [ "node_modules/parcel-bundler/bin/cli.js",
cmd,
DashboardController::PARCEL_ASSET_LIST,
"--out-dir public/dist",
"--public-url /dist" ].join(" ")
sh [intro, opts, DashboardController::PARCEL_CLI_OUTRO].join(" ")
end
desc "Serve javascript assets (via Parcel bundler)"
task serve_assets: :environment do
css = DashboardController::CSS_INPUTS.values
js = DashboardController::JS_INPUTS.values
assets = (js + css)
.sort
.uniq
.map { |x| "frontend" + x }
.join(" ")
# Clear out cache and previous builds on initial load.
sh "rm -rf .cache/ public/dist/"
parcel "watch", DashboardController::PARCEL_HMR_OPTS
end
cli = [
"node_modules/parcel-bundler/bin/cli.js",
"watch",
assets,
"--out-dir public/dist",
"--public-url /dist",
"--hmr-hostname #{ENV.fetch("API_HOST")}",
"--hmr-port 3808",
# WHY ARE SOURCE MAPS DISABLED?
# https://github.com/parcel-bundler/parcel/issues/2599#issuecomment-459131481
# https://github.com/parcel-bundler/parcel/issues/2607
# TODO: Upgrade parcel when issue ^ is fixed.
"--no-source-maps",
].join(" ")
puts "=== Running: \n#{cli}"
sh cli
desc "DELETE OLD ASSETS and build javascript/css assets via Parcel bundler"
task build_assets: :environment do
sh "rm -rf .cache/ node_modules/ public/dist/"
sh "npm install"
parcel "build"
end
desc "Reset _everything_, including your database"