A skeleton project for creating applications that use node.js server-side, backbone.js client-side, underscore.js templates, CoffeeScript as a JS pre-processor and Compass/SASS as a CSS pre-processor..
This project is from 2011 and is no longer maintained. It has been supersceded by the many node.js frameworks that are now available and tools like grunt.js and gulp.js.
This is project represents the skeleton of an application with node.js server-side and backbone.js client-side. All JavaScript is written using CoffeeScript, all CSS is written using Compass and SASS, all templates are written using underscore.js and all client-side JavaScript is packaged using Jammit. A utility class is provided that automatically recompiles & packages all of these pre-processor languages every time you hit save, so you can iterate quickly: make a code change, hit refresh.
node-backbone-skeleton is primarily for my own personal use and not a battle-tested, production-ready framework. However, I've found it useful for a few projects, so perhaps other developers will find it a handy starting point.
gem install compass
npm install glob
gem install jammit
npm install -g coffee-script
export NODE_ENV=development
to .bash_profile
)node server.js
(or node-dev server.js
to get "hot redeploy")This class is loaded by server.js
at startup to watch the project using watch-tree and recompile and package files as necessary so that you can iterate quickly. The goal is to support "make a change, hit reload" style development even though this project uses a number of pre-processors that require "compilation". It works reasonably well already and as I improve, I'll likely break this off into its own Github/NPM project.
Sample usage:
var Watcher = require('./util/watcher').watcher;
var options = {
compass: 'config/config.rb',
verbose: true,
templates: templates,
package: 'config/jammit.yml',
packageOut: 'public/js',
paths: {
'server.coffee': {type: 'coffee', out: '.'},
'templates/**/*.html': {type: 'template', out: 'compiled/templates', package: true},
'views/**/*.coffee': {type: 'coffee', out: 'compiled/views', package: true}
}
};
var watcher = new Watcher(options);
watcher.watch();
Executing the watch()
function does the following:
compass watch
if a config file is specified in options.compass
options.root
or '.'
by default) and takes action any time a file changes that matches one of the keys (globs processed using node-glob). The action taken depends on the type
:
out
out
. Also adds this template by filename into the object specified in options.templates
: e.g. if foo.html
changed, foo.js
would be created and options.templates['foo']
would be set to the compiled function.package: true
is specified, will also run Jammit using the config file specified in options.package
and put the output in the folder specified in options.packageOut