Add heroku release step
parent
e7592081d4
commit
0f5dd7aa69
1
Procfile
1
Procfile
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue