Last active
August 29, 2015 13:55
-
-
Save AdoPi/8729984 to your computer and use it in GitHub Desktop.
Gruntfile for express and livereload
This file contains hidden or 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
module.exports = function(grunt) { | |
// load all grunt tasks | |
require('load-grunt-tasks')(grunt); | |
// Configure Grunt | |
grunt.initConfig({ | |
//it will allow to run nodemon and watch at the same time | |
concurrent: { | |
dev: { | |
tasks: ['nodemon', 'watch'], | |
options: { | |
logConcurrentOutput: true | |
} | |
} | |
}, | |
compass: { | |
dev: { | |
config:'config.rb' | |
} | |
}, | |
//configure nodemon to restart when files are changed | |
nodemon: { | |
dev: { | |
script: 'app.js', | |
options: { | |
ignore: ['node_modules/**'], | |
ext: 'js,scss,css,handlebars,html', | |
nodeArgs: ['--debug'], | |
env: { | |
PORT: '3000' | |
}, | |
// omit this property if you aren't serving HTML files and | |
// don't want to open a browser tab on start | |
callback: function (nodemon) { | |
nodemon.on('log', function (event) { | |
console.log(event.colour); | |
}); | |
// opens browser on initial server start | |
nodemon.on('config:update', function () { | |
// Delay before server listens on port | |
setTimeout(function() { | |
require('open')('http://localhost:3000'); | |
}, 1000); | |
}); | |
// refreshes browser when server reboots | |
nodemon.on('restart', function () { | |
// Delay before server listens on port | |
setTimeout(function() { | |
require('fs').writeFileSync('.grunt/rebooted', 'rebooted'); | |
}, 1000); | |
}); | |
} | |
} | |
} | |
}, | |
watch: { | |
//it must be used to run express before the livereload task | |
server: { | |
files: ['.grunt/rebooted'], | |
options: { | |
livereload: true | |
} | |
}, | |
compass: { | |
// These files are sent to the live reload server | |
files: ['public/stylesheets/**/*.scss', 'public/stylesheets/*.scss'], | |
tasks: ['compass'], | |
livereload: true | |
}, | |
} | |
}); | |
grunt.registerTask('default',['concurrent:dev']); | |
}; |
This file contains hidden or 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
{ | |
"name": "express-livereload", | |
"dependencies": { | |
"express": "*" | |
}, | |
"devDependencies": { | |
"load-grunt-tasks": "~0.3.0", | |
"grunt": "~0.4.2", | |
"grunt-contrib-watch": "~0.5.3", | |
"grunt-contrib-jshint": "~0.8.0", | |
"grunt-concurrent": "~0.4.3", | |
"grunt-contrib-compass": "~0.7.1", | |
"grunt-nodemon": "~0.2.0", | |
"grunt-contrib-stylus": "~0.12.0", | |
"grunt-open": "~0.2.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment