zoukankan      html  css  js  c++  java
  • grunt项目配置

    安装完CLI,还要在项目安装Grunt

    npm install -g grunt-cli

    npm install grunt --save-dev

    源码放在src下

    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"
      }
    }
    

    打开命令行工具进入到项目根目录,敲如下命令: npm install

    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']);
    }; 
    

    进入到项目根目录,敲 grunt

    grunt官方文档http://gruntjs.com/api/grunt

  • 相关阅读:
    迭代器简介
    关于判断对象是否相等的问题
    NIO
    BIO流分类介绍
    servlet简介
    http协议简介
    爬虫常用链接
    http和https协议
    爬虫的合法性研究
    爬虫介绍
  • 原文地址:https://www.cnblogs.com/maqunjing/p/3169231.html
Copyright © 2011-2022 走看看