Skip to content

Instantly share code, notes, and snippets.

@lidaling
Forked from adion/Gruntfile.js
Created July 10, 2014 01:37
Show Gist options
  • Save lidaling/b47378f6a71248b51627 to your computer and use it in GitHub Desktop.
Save lidaling/b47378f6a71248b51627 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