zoukankan      html  css  js  c++  java
  • grunt 试用笔记

    Gruntjs是JavaScript项目的构建工具,也是基于node的一个命令行工具。很多开源JS项目都是使用它搭建。如jQuery、Qunit、CanJS等。它有以下作用

    合并JS文件
    压缩JS文件
    单元测试(基于QUnit)
    一句话:完全自动化(automation)

    以下是它的安装过程。

    一、安装node

    参考nodejs入门 (最新的node会自动安装npm)

    二、安装grunt命令行工具grunt-cli

    安装后,可以查看改工具的版本。命令: grunt -version

    三、安装grunt及其插件

    进入到某项目根目录D:zjjserverhtdocs est_gjs,使用命令: npm install grunt --save-dev 至此,安装完毕。


    1、进入项目目录,如 D:zjjserverhtdocs est_gjs,执行如下命令:npm install grunt --save-dev
    2、新建项目文件package.json

    {
    "name": "Bejs",
    "version": "0.1.0",
    "devDependencies": {
    "grunt": "~0.4.0",
    "grunt-contrib-jshint": "~0.1.1",
    "grunt-contrib-uglify": "~0.1.2",
    "grunt-contrib-concat": "~0.1.1"
    }
    }


    3、执行npm install
    4、新建文件Gruntfile.js
    module.exports = function(grunt) {
    // 配置
    grunt.initConfig({
    pkg : grunt.file.readJSON('package.json'),
    concat : {
    domop : {
    src: ['src/ajax.js', 'src/selector.js'],
    dest: 'dest/domop.js'
    }
    },
    uglify : {
    options : {
    banner : '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */ '
    },
    build : {
    src : 'dest/domop.js',
    dest : 'dest/domop.min.js'
    }
    }
    });
    // 载入concat和uglify插件,分别对于合并和压缩
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    // 注册任务
    grunt.registerTask('default', ['concat', 'uglify']);
    }; 
    5、执行grunt、至此Js压缩就完成了,转自

    http://www.cnblogs.com/snandy/archive/2013/03/11/2949177.html

    http://www.cnblogs.com/snandy/archive/2013/03/07/2946989.html

  • 相关阅读:
    HDFS详解(3)——HDFS文件结构
    HDFS详解(1)
    MapReduce工作机制
    Hadoop体系结构
    Hadoop 项目及结构
    (转)Hadoop生态系统
    Hadoop配置参数
    HDFS详解(2)——HDFS中的读写数据流
    Yarn(MapReduce V2)
    与或非实习day02
  • 原文地址:https://www.cnblogs.com/naledao/p/3376114.html
Copyright © 2011-2022 走看看