zoukankan      html  css  js  c++  java
  • 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']);
    }
  • 相关阅读:
    简单错误记录
    识别有效的IP地址和掩码并进行分类统
    爬虫必备—BeautifulSoup
    爬虫必备—requests
    Shellinabox安装及使用教程
    Django——REST framework
    SaltStack部署
    使用js在HTML中自定义字符串格式化方法
    3种上传图片并实现预览的方法
    Ajax
  • 原文地址:https://www.cnblogs.com/hutuzhu/p/4444911.html
Copyright © 2011-2022 走看看