浏览代码

Add cssmin and copy to grunt tasks

phuoc 12 年之前
父节点
当前提交
c3146b0641
共有 2 个文件被更改,包括 27 次插入3 次删除
  1. 24 2
      Gruntfile.js
  2. 3 1
      package.json

+ 24 - 2
Gruntfile.js

@@ -16,6 +16,26 @@ module.exports = function(grunt) {
             ' */\n\n'
         ].join('\n'),
 
+        copy: {
+            main: {
+                files: [
+                    { cwd: 'src/css', src: '**', dest: '<%= buildDir %>/css', expand: true, flatten: true, filter: 'isFile' }
+                ]
+            }
+        },
+
+        cssmin: {
+            minify: { expand: true, cwd: 'src/css/', src: ['*.css'], dest: '<%= buildDir %>/css/', ext: '.min.css' },
+            add_banner: {
+                options: {
+                    banner: '<%= banner %>'
+                },
+                files: {
+                    '<%= buildDir %>/css/bootstrapvalidate.min.css': ['src/css/bootstrapvalidate.css']
+                }
+            }
+        },
+
         concat: {
             options: {
                 separator: ';',
@@ -40,7 +60,7 @@ module.exports = function(grunt) {
 
         watch: {
             scripts: {
-                files: ['src/js/**'],
+                files: ['src/css/**', 'src/js/**'],
                 tasks: ['build'],
                 options: {
                     spawn: false
@@ -50,9 +70,11 @@ module.exports = function(grunt) {
     });
 
     grunt.registerTask('default', 'build');
-    grunt.registerTask('build', ['concat', 'uglify']);
+    grunt.registerTask('build', ['copy', 'cssmin', 'concat', 'uglify']);
 
     grunt.loadNpmTasks('grunt-contrib-concat');
+    grunt.loadNpmTasks('grunt-contrib-copy');
+    grunt.loadNpmTasks('grunt-contrib-cssmin');
     grunt.loadNpmTasks('grunt-contrib-uglify');
     grunt.loadNpmTasks('grunt-contrib-watch');
 };

+ 3 - 1
package.json

@@ -9,7 +9,9 @@
     "grunt": "~0.4.1",
     "grunt-contrib-uglify": "~0.2.4",
     "grunt-contrib-concat": "~0.3.0",
-    "grunt-contrib-watch": "~0.5.3"
+    "grunt-contrib-watch": "~0.5.3",
+    "grunt-contrib-cssmin": "~0.6.2",
+    "grunt-contrib-copy": "~0.4.1"
   },
   "version": "0.1.0"
 }