Git Product home page Git Product logo

catapult's Introduction

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']]
}

catapult's People

Contributors

maccman avatar alex-stripe avatar lucasmazza avatar ejholmes avatar

Watchers

James Cloos avatar

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.