Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Sprockets/Rack build tool
branch: master

Merge pull request #10 from SaitoWu/master

bump dependencies version to improve the performace
latest commit 911266797a
Alex MacCaw authored
Failed to load latest commit information.
bin implement
example add --compile options to use uglifier/yui-compressor to compile JS/CSS
lib fix for the stylus API change
templates/app add --compile options to use uglifier/yui-compressor to compile JS/CSS
.gitignore
Gemfile add --compile options to use uglifier/yui-compressor to compile JS/CSS
LICENSE add MIT License
README.md more docs
Rakefile implement
catapult.gemspec add rb-fsevent for performance

README.md

Catapult

Simple gem that gives pure JavaScript/CoffeeScript projects a basic structure, and manages any necessary compilation and concatenation.

Catapult is especially useful alongside MVC frameworks like Spine and Backbone.

Installation

$ gem install catapult

Usage

To generate an app, use:

$ catapult new myapp

  create  myapp
  create  myapp/assets/javascripts/app.js
  create  myapp/assets/stylesheets/app.css
  create  myapp/browser.json
  create  myapp/public/index.htm

$ cd myapp

You'll notice a bunch of files have been created. The convention in Catapult is that any assets under assets/javascripts and assets/stylsheets will be compiled under the static public directory. Your HTML files can reference them there.

Now you can start a catapult server:

$ catapult server

And open up the app in your browser.

You can also build the files for deployment:

$ catapult build

Or watch the files for changes, and then automatically build:

$ catapult watch

Concatenation

Catapult uses Sprockets for concatenation. Sprockets uses meta comments to specify dependencies. For example:

//= require jquery
//= require ./other_file
//= require_tree ./app

See the Sprockets documentation for more information.

Included compilers

Sprockets will automatically compile certain file types when the files are first requested. For example, files with .coffee extensions will be compiled down to JavaScript before being served up to the end user.

The included Sprockets compilers are: CoffeeScript, sprockets-commonjs and Stylus. You can include additional ones by simply adding them to your project's Gemfile.

Deploying to Heroku

It's a good idea to just serve up static files in production, and disable the asset compilation.

If you're using a system like Apache, you can just serve up the static files under the ./public dir. Otherwise, with a Rack based system, like Heroku, you're going to need a few files:

Firstly, a Gemfile:

source 'https://rubygems.org'
gem 'catapult'

Then a config.ru file, serving up the static files:

require 'catapult'

use Catapult::TryStatic,
    :root => Catapult.root.join('public'),
    :urls => %w[/],
    :try  => ['.html', 'index.html', '/index.html']

run lambda {|env|
  [404, {}, ['Not found']]
}
Something went wrong with that request. Please try again.