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

  • 相关阅读:
    WP8日历(含农历)APP
    NHibernate3剖析:Mapping篇之集合映射基础(2):Bag映射
    初探springmvc
    树的子结构
    Java内存分析
    java8_api_misc
    iOS开发多线程篇 09 —NSOperation简单介绍
    CALayer1-简介
    NSCharacterSet
    iOS 音频开发
  • 原文地址:https://www.cnblogs.com/benchan2015/p/4746456.html
Copyright © 2011-2022 走看看