diff --git a/Gruntfile.js b/Gruntfile.js index cae5ad6..2d5faac 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,6 +12,32 @@ module.exports = function(grunt) { } } }, + connect: { + server: { + options: { + port: 9003, + livereload: 35732, + open: true, + hostname: '0.0.0.0', // to be able to access the server not only from localhost + base: { + path: '.' + } + } + } + }, + clean: { + dist: { + files: [{ + dot: true, + src: [ + '.sass-cache', + '.tmp', + 'dist', + '!dist/.git*' + ] + }] + } + }, sass: { dist: { options: { @@ -40,6 +66,11 @@ module.exports = function(grunt) { } } }, + shell: { + dist: { + command: 'styleguide' + } + }, watch: { scss: { files: [ @@ -58,8 +89,25 @@ module.exports = function(grunt) { } }); - grunt.registerTask('default', ['sass', 'concat', 'cssmin', 'watch:scss']); + var baseTasks = [ + 'clean', + 'sass', + 'concat', + 'cssmin' + ]; + var devTasks = baseTasks.concat([ + 'connect', + 'watch:scss' + ]); + + grunt.event.on('watch', function (action, filepath) { + grunt.task.run('shell'); + }); + + grunt.registerTask('dev', devTasks); + grunt.registerTask('build', baseTasks); + grunt.registerTask('default', baseTasks); }; // diff --git a/package.json b/package.json index 27b3216..2704ff9 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,10 @@ "highlight.js": "~9.1.0", "markdown-styleguide-generator": "~2.0.4", "grunt-sass": "1.1.0", + "grunt-contrib-clean": "0.7.0", "grunt-contrib-concat": "0.5.1", "grunt-contrib-cssmin": "0.14.0", + "grunt-contrib-connect": "0.11.2", "grunt-contrib-watch": "0.6.1", "grunt-shell": "1.1.2", "load-grunt-tasks": "*"