zoukankan      html  css  js  c++  java
  • grunt之easy demo

    首先安装grunt-cli

    cnpm install -g grunt-cli

    接下来创建package.json,内容如下

        {  
          "name": "demo",  
          "file": "zepto",  
          "version": "0.1.0",  
          "description": "demo",  
          "license": "MIT",  
          "devDependencies": {  
            "grunt": "~0.4.1",  
            "grunt-contrib-jshint": "~0.6.3",  
            "grunt-contrib-concat": "~0.5.0",  
            "grunt-contrib-uglify": "~0.2.1",  
            "grunt-contrib-requirejs": "~0.4.1",  
            "grunt-contrib-copy": "~0.4.1",  
            "grunt-contrib-clean": "~0.5.0",  
            "grunt-strip": "~0.2.1"  
          },  
          "dependencies": {  
            "express": "3.x"  
          }  
        } 

    也可以使用npm init来进行初始化

    创建Gruntfile.js,只做合并和压缩

        module.exports = function (grunt) {  
          grunt.initConfig({  
          concat: {  
            options: {  
            },  
            dist: {  
              src: ['src/**/*.js'],//src文件夹下包括子文件夹下的所有文件  
              dest: 'dist/built.js'//合并文件在dist下名为built.js的文件  
            }  
          },  
          uglify: {  
             build: {  
                src: 'dist/built.js',//压缩源文件是之前合并的buildt.js文件  
                dest: 'dist/built.min.js'//压缩文件为built.min.js  
              }  
           }  
        });  
          grunt.loadNpmTasks('grunt-contrib-uglify');  
          grunt.loadNpmTasks('grunt-contrib-concat');  
            
          grunt.registerTask('default', ['concat','uglify']);  
        } 

    接下来执行cnpm(npm) install,下载好依赖包

    接下来执行grunt

  • 相关阅读:
    Study Plan The TwentySecond Day
    Study Plan The Nineteenth Day
    Study Plan The TwentySeventh Day
    Study Plan The Twentieth Day
    Study Plan The TwentyFirst Day
    python实现进程的三种方式及其区别
    yum makecache
    JSONPath 表达式的使用
    oracle执行cmd的实现方法
    php daodb插入、更新与删除数据
  • 原文地址:https://www.cnblogs.com/benchan2015/p/4746456.html
Copyright © 2011-2022 走看看