Skip to content

Instantly share code, notes, and snippets.

@sirbrillig
Created July 17, 2014 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirbrillig/127bf589cbb0ebf1176d to your computer and use it in GitHub Desktop.
Save sirbrillig/127bf589cbb0ebf1176d to your computer and use it in GitHub Desktop.
Grunt task to run node server with jQuery, Browserify, and Handlebars
var loadTasks = require( 'load-grunt-tasks' );
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
nodemon: {
dev: {
script: 'server.js',
options: {
watch: [ 'public' ]
}
}
},
handlebars: {
compile: {
options: {
namespace: false,
commonjs: true
},
src: 'app/templates/**/*.hbs',
dest: 'app/templates/compiledTemplates.js'
}
},
browserify: {
options: {
debug: true,
watch: true,
shim: {
jquery: {
path: 'public/js/vendor/jquery-1.10.2.min.js',
exports: '$'
}
}
},
dev: {
src: [ 'app/**/*.js' ],
dest: 'public/js/bundle.js'
},
production: {
options: {
debug: false
},
src: [ 'app/**/*.js' ],
dest: 'public/js/bundle.js'
}
}
});
// load all grunt tasks matching the `grunt-*` pattern
loadTasks( grunt );
grunt.registerTask('compile', [ 'handlebars', 'browserify:dev' ]);
// Default task(s).
grunt.registerTask('default', ['compile', 'nodemon']);
};
var express = require( 'express' ),
app = express(),
server;
app.use( express.static( __dirname + '/public' ) );
server = app.listen( 3000, function() {
console.log('listening on port %d', server.address().port);
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment