Bedrock & Roots: Building Production Assets on the Server

I just finished another post on dealing with generated production assets with Bedrock and Roots. This one details building the production assets on the server.

The short version:

  1. Install Node, Bower, and Grunt on the server.

  2. Add capistrano-npm and capistrano-grunt to your Gemfile.

  3. Require ‘capistrano/npm’ and ‘capistrano/grunt’ in your Capfile.

  4. Add some lines to config/deploy.rb

    set :npm_target_path, -> { release_path.join(‘web/app/themes/roots’) }
    set :npm_flags, ‘–silent’

    set :grunt_file, -> { release_path.join(‘web/app/themes/roots/Gruntfile.js’) }
    set :grunt_tasks, 'build’
    before ‘deploy:updated’, ‘grunt’

Hopefully this is helpful to someone. If you try it, let me know if you have issues or if anything’s unclear, and I’ll try to help get things sorted out.

4 Likes