Asset Bundling for Capistrano 3

his is part of a series of articles on rewriting a LAMP deploy stack to use Capistrano 3. Asset bundles are a simple way to optimise asset file serving especially if you'd prefer not to use a heavier asset system.

This is part of a series of articles on rewriting a LAMP deploy stack to use Capistrano 3.

Whilst there are quite a few fully featured asset bundlers available, if you'd prefer a simpler, filesystem driven approach then this may help.

Take the following typical asset layout:

public/
  stylesheets/
    resets/
      fonts.css
      typography.css
      main.css
    core/
      headers.css
      colors.css
      navigation.css
    blog/
      styles.css
    news/
      styles.css

This capistrano bundle deployer, splits your assets up into modules based on the top-level directory, giving you combined builds of each. The above setup would yield the following build files:

public/
  stylesheets/
    build/
      resets_combined.css
      core_combined.css
      blog_combined.css
      news_combined.css

You can then use the built versions in production.

The project is so-far only a basic version, there's lots more features to come, but if you'd like something implemented head over to the capistrano bundle projct on github and open an issue.