Skip to content

Instantly share code, notes, and snippets.

@swalkinshaw
Last active February 28, 2017 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swalkinshaw/7fba3ab806cdba974db4ab0083639e61 to your computer and use it in GitHub Desktop.
Save swalkinshaw/7fba3ab806cdba974db4ab0083639e61 to your computer and use it in GitHub Desktop.
Sage + Capistrano
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Load tasks from gems
require 'capistrano/bower'
require 'capistrano/gulp'
require 'capistrano/npm'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
# Customize this path to change the location of your custom tasks.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
set :application, 'my_app_name'
set :repo_url, 'git@example.com:me/my_repo.git'
set :branch, :master
set :deploy_to, -> { "/srv/www/#{fetch(:application)}" }
set :log_level, :info
# rest of the usual config
set :npm_flags, %w(--silent --no-progress)
set :gulp_tasks, '--production'
set :gulp_file, -> { release_path.join('path/to/sage/Gulpfile.js') }
set :gulp_target_path, -> { release_path.join('path/to/sage') }
namespace :deploy do
before :updated, 'gulp'
end
gem 'capistrano'
gem 'capistrano-bower'
gem 'capistrano-gulp'
gem 'capistrano-npm'
@alicam
Copy link

alicam commented Aug 9, 2016

Also read elsewhere that set :gulp_tasks, '--production' is not appropriate for staging because it means that the devDependencies in package.json are skipped? So I have removed that, assuming that's true(?).

@swalkinshaw
Copy link
Author

Try adding set :npm_flags, %w(--silent --no-progress). You are right about devDependencies but had the wrong place. That's to do with npm and not gulp.

@alicam
Copy link

alicam commented Aug 10, 2016

Excellent. Last one, I hope!

The dependency "tree" on my local/dev machine ends up creating tons of node_modules directories. But in staging, there are many fewer. And then I get dependency errors when the gulp task runs, saying dependent modules weren't found.

Should the staging/prod server configs mean that a different number of node_modules be loaded?? Seems strange.

@alicam
Copy link

alicam commented Aug 10, 2016

No wait. It worked later. Possible an i/o error on the machine?! Scratch that either way!

@rjksn
Copy link

rjksn commented Feb 28, 2017

Is this still relevant since it seems 9.0.0-beta.2 uses yarn instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment