Giter VIP home page Giter VIP logo

capistrano-local-precompile's Introduction

Capistrano Local Precompile

If your Rails apps are anything like mine, one of the slowest parts of your deployment is waiting for asset pipeline precompilation. It's sometimes so slow, it's painful. So I went searching for some solutions. turbo-sprockets helped, but it's not a silver bullet. This gem isn't a silver bullet either, but it can help. Capistrano Local Precompile takes a different approach. It builds your assets locally and rsync's them to your web server(s).

Note: This gem is not yet compatible with Capistrano 3.

Usage

Add capistrano-local-precompile to your Gemfile:

group :development do
  gem 'capistrano-local-precompile', require: false
end

Then add the following line to your deploy.rb:

require 'capistrano/local_precompile'

If you are using turbo-sprockets, just set it to enabled. Your asset will still compile locally, but they'll use turbosprockets to do so:

set :turbosprockets_enabled, true

If you don't want to grant access to production's database from outside you can add:

set :use_local_env, true

and local precompile will happen with a custom environment. For example if your production's environment is setup as 'production', enabling :use_local_env precompile will happen with 'production-local' environment. To make it work you will have to define the new environment but it's worth to don't open your production's database to everyone.

Here's the full set of configurable options:

set :precompile_cmd             # default: bundle exec rake assets:precompile
set :assets_dir                 # default: "public/assets"
set :rsync_cmd                  # default: "rsync -av"

set :turbosprockets_enabled     # default: false
set :turbosprockets_backup_dir  # default: "public/.assets"
set :cleanexpired_cmd           # default: bundle exec rake assets:clean_expired
set :use_local_env              # default: false

Acknowledgement

This gem is derived from gists by uhlenbrock and keighl.

Contributing

Pull requests welcome: fork, make a topic branch, commit (squash when possible) with tests and I'll happily consider.

Copyright

Copyright (c) 2013 Steve Agalloco. See LICENSE for detail

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.