Info

I'm a follower of Jesus, a father and a fiancé. I'm a UX Designer at Pure Charity. I podcast at Founders Talk, The Changelog and The Industry

Posts from the Web Category

Choose another category?

Much like the Using Rake and Rsync for WordPress deployment post that I posted a few days back, this post is to reference a simple Rakefile I wrote to help me easily manage common development tasks when working with StaticMatic.

Rakefile features:

  • Clear and generate tasks that clear and generate new styles (via Compass)
  • Preview, build tasks that preview and build the StaticMatic site using the default StaticMatic commands (I hate typing staticmatic over and over and over…)
  • Deploy task using Rsync that clears the styles, generates new styles, builds the site, and finally deploys the site using Rsync

I also created a StaticMatic-Bootstrap that you are welcome to “watch” or “fork” on GitHub.

It supports: Haml, Sass, Compass and jQuery out of the box and comes with said Rakefile noted in this post.

Like most web developers. I prefer to save time by automating low level, mundane tasks.

Laziness is a trait of a good developer.

When I started to use WordPress again, I WAS NOT excited about using the FTP protocol to ship off changes to my theme. I wanted a simple and easy use process to deploy updates to my theme and also automate a few processes that I needed to support as part of using Sass and Compass to create my CSS styles.

What’s the alternative? FTP? Nope. Typing the rsync command by hand each time? Nope again.

This is a simple Rakefile I wrote that helps me to do all this in simple and concise manner.

Features:

  • Clear and generate tasks that clear and generate new styles (via Compass)
  • Deploy task that clears the styles, generates new styles and finally deploys the theme using Rsync
ssh_user = "user@domain.com" # for rsync deployment
remote_root = "~/path/to/remote/" # for rsync deployment

namespace :styles do
  desc "Clear styles"
  task :clear do
    puts "*** Clearing styles ***"
    system "compass clean"
  end
  desc "Generate styles"
  task :generate => [:clear] do
    puts "*** Generating styles ***"
    system "compass compile"
  end
end

desc "Clears the styles, generates new ones and then deploys the theme"
task :deploy => 'styles:generate' do
  puts "*** Deploying the site ***"
  system("rsync -avz --delete . #{ssh_user}:#{remote_root}")
end

It’s 21 lines and simple to use. Besides, rake deploy is much better than what most WordPress users are doing to deploy updates to their theme. Capistrano could work too, but IMO would be over-kill. Rsync is a much better fit, and using the --delete option ensures that you delete files that don’t exist on the sending side. Keeps it simple and clean.

This Rakefile is a bit opinionated and assumes you’re using Sass and Compass.