Skip to content

Instantly share code, notes, and snippets.

@stephenplusplus
Created May 18, 2013 13:53
Show Gist options
  • Save stephenplusplus/5604474 to your computer and use it in GitHub Desktop.
Save stephenplusplus/5604474 to your computer and use it in GitHub Desktop.
// Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %>
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
watch: {
options: {
nospawn: true,
livereload: LIVERELOAD_PORT
},
livereload: {
files: [
'index.html'
]
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, '.')
];
}
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.options.port %>'
}
}
});
grunt.registerTask('server', ['connect:livereload', 'open', 'watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment