Skip to content

Instantly share code, notes, and snippets.

@Johnqing
Last active December 14, 2015 19:59
Show Gist options
  • Select an option

  • Save Johnqing/5140671 to your computer and use it in GitHub Desktop.

Select an option

Save Johnqing/5140671 to your computer and use it in GitHub Desktop.

Revisions

  1. Johnqing revised this gist Mar 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gruntjs 0.4 入门
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@
    "grunt-contrib-concat": "~0.1.1"
    }
    }
    6.在项目根目录运行命令: npm install
    6.在项目根目录运行命令: npm install (不带模块名会安装一些基础模块,npm install xx --save-dev)
    7.查看项目中node_modules目录,是否包含
    grunt
    grunt-contrib-concat
  2. Johnqing revised this gist Mar 12, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gruntjs 0.4 入门
    Original file line number Diff line number Diff line change
    @@ -37,6 +37,8 @@
    });
    //载入concat模块
    grunt.loadNpmTasks('grunt-contrib-concat');
    // 注册任务(0.4后貌似需要[]来添加注册模块)
    grunt.registerTask('default', ['concat']);
    }
    9.运行命令:grunt,显示如下:
    Running "default" task
  3. Johnqing renamed this gist Mar 12, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. Johnqing created this gist Mar 12, 2013.
    46 changes: 46 additions & 0 deletions gruntjs 4.0 入门
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    (注意:本教程前提为未安装gruntjs其他版本,如果安装请删除!)
    1.安装node(在此不做介绍)
    2.运行命令: npm install -g grunt-cli(-g为全局安装,可在任何目录运行)
    3.进入项目目录,运行命令: npm install grunt --save-dev
    4.查看是否安装成功 grunt -version
    成功显示: grunt-cli v0.1.6 grunt v0.4.0
    5.新建package.json
    如下:
    {
    "name": "51",
    "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"
    }
    }
    6.在项目根目录运行命令: npm install
    7.查看项目中node_modules目录,是否包含
    grunt
    grunt-contrib-concat
    grunt-contrib-jshint
    grunt-contrib-uglify
    8.新建Gruntfile.js,结构如下:
    module.exports = function(grunt) {
    grunt.initConfig({
    concat: {
    options: {
    separator: ';'
    },
    dist: {
    src: ['assets/seajs/seajs.js', assets/init/config.js', 'assets/init/main.js', 'assets/init/category.js', 'assets/init/fimg.js', 'assets/init/lazyload.js'],
    dest: 'dist/built.js'
    }
    }
    });
    //载入concat模块
    grunt.loadNpmTasks('grunt-contrib-concat');
    }
    9.运行命令:grunt,显示如下:
    Running "default" task
    default

    Done, without errors.
    10.完成。