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"
    }
  • 相关阅读:
    pip的认识
    java动态代理
    hadoop集群环境配置成功与否查看方法
    input输入框只能输入数字、字母相关组合
    ASP.NET Core MVC上传、导入、导出知多少
    MQTT
    高德地图
    油猴脚本
    excel中001如何输入
    WebPageBase.IsSectionDefined(String) 方法
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4100953.html
Copyright © 2011-2022 走看看