I wanted to have a single default grunt command kick off my Jekyll server (jekyll serve --watch
), and my grunt watch task. After sleuthing around StackOverflow, I found a solution using grunt-jekyll and grunt-concurrent. Concurrency is needed to prevent the jekyll server from blocking.
module.exports = function(grunt) {
grunt.initConfig({
jekyll: {
serve: {
options: {
serve: true,
watch: true
}
}
},
less: {
development: {
options: {
paths: ['./less'],
yuicompress: true
},
files: {
'css/main.css': 'less/main.less'
}
}
},
watch: {
less: {
files: ['less/**/*.less'],
tasks: ['less']
}
},
concurrent: {
all: {
tasks: ['jekyll:serve', 'watch'],
options: {
logConcurrentOutput: true
}
}
}
});
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default', ['concurrent:all']);
};