zoukankan      html  css  js  c++  java
  • [Grunt] External Config

    Let's combine uglifying, watching, and config stuff into one Grunt file to make it more of a standard Grunt file.

    Install:


    npm install grunt
    npm install grunt-contrib-watch
    npm install grunt-contrib-uglify

    Example:


    /**
     * Created by Answer1215 on 11/15/2014.
     */
    module.exports = function(grunt){
    
        // Version one
        //grunt.initConfig({
        //
        //    uglify:{
        //        dist:{
        //            files:{
        //               "dist/app.min.js": "app/**/*.js"
        //            }
        //        }
        //    },
        //    watch:{
        //        files:"app/**/*.js",
        //        tasks: 'uglify'
        //   }
        //});
    
        //version two: using template
        //grunt.initConfig({
        //    conf: {
        //        input: "app/**/*.js"
        //    },
        //    uglify:{
        //        dist:{
        //            files:{
        //                "dist/app.min.js": "<%= conf.input %>"
        //            }
        //        }
        //    },
        //    watch:{
        //        files: "<%= conf.input %>",
        //        tasks: 'uglify'
        //   }
        //});
    
    
        //version three:  using config json file
    
        grunt.initConfig({
            conf: grunt.file.readJSON('config.json'),
            uglify: {
                dist:{
                    files:{
                        "dist/app.min.js": "<%= conf.input %>"
                    }
                }
            },
            watch: {
                files: "<%= conf.input %>",
                tasks: ['uglify']
            }
        });
    
        grunt.loadNpmTasks('grunt-contrib-watch');
        grunt.loadNpmTasks('grunt-contrib-uglify');
    }

     config.json

    {
      "input": "app/**/*.js"
    }
  • 相关阅读:
    16-高级指针
    15-C语言结构体
    14-C语言宏
    13-C语言字符串函数库
    12-C语言字符串
    11-C语言指针
    10-C语言函数
    POJ 1001 高精度乘法
    POJ 1060 多项式乘法和除法取余
    POJ 1318 字典排序
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4100953.html
Copyright © 2011-2022 走看看