首页 > 其他 > 详细

Grunt实例

时间:2015-04-21 19:55:47      阅读:187      评论:0      收藏:0      [点我收藏+]
module.exports = function(grunt) {
  // 项目配置
  grunt.initConfig({
    pkg: grunt.file.readJSON(‘package.json‘),
    clean:{//清除目标文件下文件
      huzhao:{
        src:"dest"
      }
    },
    uglify: {
      huzhao: {
        files: [{
          expand: true,
          cwd: ‘src‘, //js目录下
          src: ‘*.js‘, //所有js文件
          dest: ‘dest‘ //输出到此目录下
        }]
      }
    },
    cssmin:{//压缩css
      huzhao:{
         "files": {
          ‘dest/main.css‘: [‘src/*.css‘]
        }
      }
    },
    htmlmin:{//压缩html
      huzhao: {
        options: { // Target options
          removeComments: true,
          collapseWhitespace: true
        },
        files:[{
          expand: true, // Enable dynamic expansion.
          cwd: ‘src/‘, // Src matches are relative to this path.
          src: [‘*.html‘], // Actual pattern(s) to match.
          dest: ‘dest/‘, // Destination path prefix.
          ext: ‘.html‘, // Dest filepaths will have this extension.
          extDot: ‘first‘ // Extensions in filenames begin after the first dot
        }]
      }
    }
  });
  // 加载提供"uglify"任务的插件
  grunt.loadNpmTasks(‘grunt-contrib-clean‘);
  grunt.loadNpmTasks(‘grunt-contrib-copy‘);
  grunt.loadNpmTasks(‘grunt-contrib-uglify‘);
  grunt.loadNpmTasks(‘grunt-contrib-concat‘);
  grunt.loadNpmTasks(‘grunt-contrib-cssmin‘);
  grunt.loadNpmTasks(‘grunt-contrib-htmlmin‘);
  // 默认任务
  grunt.registerTask(‘huzhao‘, [‘clean:huzhao‘,‘uglify:huzhao‘, ‘cssmin:huzhao‘, ‘htmlmin:huzhao‘]);
}

 

Grunt实例

原文:http://www.cnblogs.com/hutuzhu/p/4444911.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!