Skip to content

Instantly share code, notes, and snippets.

@872409
Forked from adion/Gruntfile.js
Created May 15, 2014 12:45
Show Gist options
  • Save 872409/c3863c16a3a0fced954b to your computer and use it in GitHub Desktop.
Save 872409/c3863c16a3a0fced954b to your computer and use it in GitHub Desktop.
'use strict';
var
LIVERELOAD_PORT = 35729,
lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT }),
mountFolder = function( connect, dir ) {
return connect.static(require('path').resolve(dir));
};
module.exports = function( grunt ) {
// load all grunt tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-open');
grunt.initConfig({
watch: {
livereload: {
files: [
'{,*/}*.html',
'static/{,*/}*.{css,js,png,jpg,gif,svg}'
],
tasks: ['jshint'],
options: {
livereload: LIVERELOAD_PORT
}
}
},
connect: {
options: {
port: 9000,
hostname: '0.0.0.0'
},
livereload: {
options: {
middleware: function( connect ) {
return [
lrSnippet,
mountFolder(connect, './')
];
}
}
}
},
open: {
server: {
url: 'http://localhost:<%= connect.options.port %>'
}
}
});
grunt.registerTask('server', function() {
grunt.task.run([
'connect:livereload',
'open',
'watch'
]);
});
grunt.registerTask('default', [ 'server' ]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment