Grunt 인스턴스

4811 단어 grunt
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' // 
        }]
      }
    },
    sass: {
      huzhao: {
        files: [{
          expand: true,
          cwd: 'src',
          src: ['*.scss'],
          dest: 'dest',
          ext: '.css'
        }]
      }
    },
    cssmin: { // css
      huzhao: {
        "files": {
          'dest/main.css': ['dest/*.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.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  //  
  grunt.registerTask('huzhao', ['clean:huzhao', 'uglify:huzhao', 'sass:huzhao', 'cssmin:huzhao', 'htmlmin:huzhao']);
}

좋은 웹페이지 즐겨찾기