Created
July 17, 2014 16:26
-
-
Save sirbrillig/127bf589cbb0ebf1176d to your computer and use it in GitHub Desktop.
Grunt task to run node server with jQuery, Browserify, and Handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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