Browse Source

Add watch task: Watch the changed files and generate the scripts

phuoc 12 years ago
parent
commit
fb348c5933
3 changed files with 20 additions and 1 deletions
  1. 11 0
      Gruntfile.js
  2. 7 0
      README.md
  3. 2 1
      package.json

+ 11 - 0
Gruntfile.js

@@ -36,6 +36,16 @@ module.exports = function(grunt) {
                 src: ['<%= buildDir %>/js/bootstrapvalidate.js'],
                 dest: '<%= buildDir %>/js/bootstrapvalidate.min.js'
             }
+        },
+
+        watch: {
+            scripts: {
+                files: ['src/js/**'],
+                tasks: ['build'],
+                options: {
+                    spawn: false
+                }
+            }
         }
     });
 
@@ -44,4 +54,5 @@ module.exports = function(grunt) {
 
     grunt.loadNpmTasks('grunt-contrib-concat');
     grunt.loadNpmTasks('grunt-contrib-uglify');
+    grunt.loadNpmTasks('grunt-contrib-watch');
 };

+ 7 - 0
README.md

@@ -90,6 +90,7 @@ From the BootstrapValidate root directory, execute the following commands to ins
 $ npm install grunt --save-dev
 $ npm install grunt-contrib-concat --save-dev
 $ npm install grunt-contrib-uglify --save-dev
+$ npm install grunt-contrib-watch --save-dev
 ```
 
 Then, uses grunt to build:
@@ -98,6 +99,12 @@ Then, uses grunt to build:
 $ grunt
 ```
 
+If you want grunt to generate scripts whenever the original scripts (located in ```src```) change, use the following command:
+
+```bash
+$ grunt watch
+```
+
 The generated scripts (including source and compressed versions) are placed inside the ```dist``` directory.
 
 ## Author

+ 2 - 1
package.json

@@ -8,7 +8,8 @@
   "devDependencies": {
     "grunt": "~0.4.1",
     "grunt-contrib-uglify": "~0.2.4",
-    "grunt-contrib-concat": "~0.3.0"
+    "grunt-contrib-concat": "~0.3.0",
+    "grunt-contrib-watch": "~0.5.3"
   },
   "version": "0.1.0"
 }