diff --git a/Gruntfile.js b/Gruntfile.js index 5670175..0a5656f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,6 +9,17 @@ module.exports = function (grunt) { // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); + let jsFiles = [ + 'src/module.js', + '.tmp/templates.js', + 'src/image-loader-service.js', + 'src/lightbox-service.js', + 'src/lightbox-src-directive.js' + ]; + let cssFiles = [ + 'src/<%= library.name %>.css', + ]; + grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), library: grunt.file.readJSON('bower.json'), @@ -17,19 +28,11 @@ module.exports = function (grunt) { separator: '' }, library: { - src: [ - 'src/module.js', - '.tmp/templates.js', - 'src/image-loader-service.js', - 'src/lightbox-service.js', - 'src/lightbox-src-directive.js' - ], + src: jsFiles, dest: 'dist/<%= library.name %>.js' }, css: { - src: [ - 'src/<%= library.name %>.css', - ], + src: cssFiles, dest: 'dist/<%= library.name %>.css' } }, @@ -91,6 +94,12 @@ module.exports = function (grunt) { dest: 'api.md' } }, + watch: { + dev: { + files: jsFiles.concat(cssFiles), + tasks: ['default'] + } + } }); grunt.registerTask('default', [ diff --git a/README.md b/README.md index e4e3fbe..bf5b511 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,12 @@ For now, the maximum video dimensions are fixed at 1280x720 (16:9). grunt ``` +* Watch source files and build automatically on changes: + + ```sh + grunt watch + ``` + * Generate docs: ```sh diff --git a/package.json b/package.json index f190a28..9545fd4 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "grunt-contrib-htmlmin": "^0.5.0", "grunt-contrib-jshint": "^0.11.3", "grunt-contrib-uglify": "^0.9.2", + "grunt-contrib-watch": "^1.0.0", "grunt-jsdoc-to-markdown": "^1.1.1", "grunt-ng-annotate": "^1.0.1", "jit-grunt": "^0.9.1",