Skip to content

Instantly share code, notes, and snippets.

@kyeotic
Created April 4, 2014 05:52
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 kyeotic/9968875 to your computer and use it in GitHub Desktop.
Save kyeotic/9968875 to your computer and use it in GitHub Desktop.
LiveReload with Grunt and Grunt-Express
// Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
module.exports = function(grunt) {
var port = 3000;
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configure Grunt
grunt.initConfig({
express: {
all: {
options: {
port: port,
hostname: "localhost",
bases: [__dirname],
livereload: true
}
}
},
watch: {
all: {
files: ['**/*.{js,css,html}', '!Gruntfile.js'],
options: {
livereload: true
}
}
},
// grunt-open will open your browser at the project's URL
open: {
all: {
path: 'http://localhost:<%= express.all.options.port%>'
}
}
});
grunt.registerTask('default', ['express', 'open', 'watch']);
};
"devDependencies": {
"grunt": "~0.4.1",
"matchdep": "~0.1.2",
"grunt-express": "~1.0.0-beta2",
"grunt-contrib-watch": "~0.5.1",
"grunt-open": "~0.2.1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment