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

[Grunt] External Config的更多相关文章

  1. scales小谈grunt

    Grunt是基于Node.js的项目构建工具.它可以自动运行你所设定的任务.Grunt拥有数量庞大的插件,几乎任何你所要做的事情都可以用Grunt实现. 一头野猪映入眼帘,意:咕噜声 中文网站:htt ...

  2. NginX issues HTTP 499 error after 60 seconds despite config. (PHP and AWS)

    FROM: http://stackoverflow.com/questions/15613452/nginx-issues-http-499-error-after-60-seconds-despi ...

  3. Grunt 实战

    专题截图:(注:这个截图没啥意义) 项目截图: 目录讲解: app/        //开发目录; c/     //开发编译完成css文件夹; i/     //开发img文件夹; j/     / ...

  4. Grunt经常使用插件及演示样例说明

    下述给出了经常使用Grunt插件,并列举了部分插件演示样例: 插件名称 说明 Github地址 grunt-contrib-clean 清空文件和目录 https://github.com/grunt ...

  5. grunt学习二

    1. 新建文件和文件目录 mkdir grunt-in-action cd grunt-in-action cd grunt-in-action mkdir grunt-empty cd grunt- ...

  6. grunt学习一

    grunt是前端自动化工具之一.下面是是grunt的简单小示例: 在使用grunt,确保安装nodejs,如果不清楚,可以百度找相关教程,这个教程已经烂大街了. 1.打开cmd,以管理员的身份.(或者 ...

  7. 10 Things ASP.NET Developers Should Know About Web.config Inheritance and Overrides(转)

    10 Things ASP.NET Developers Should Know About Web.config Inheritance and Overrides Wednesday, Janua ...

  8. yeomen/bower/grunt

    yeomen: npm install yo angular-in-action project npm install -g generator-angular npm install -g gen ...

  9. grunt配置详情

    这个grunt配置 是我的一个程序员朋友从网上无意间看到的,然后他亲测了下,恩,是可以的.不过我到目前还未测试过是否可以. 一.安装node, 首先确保电脑已有node的环境.然后 运行  npm i ...

随机推荐

  1. Python并发编程-SocketServer多线程版

    #server.py import socket from threading import Thread def chat(conn): conn.send(b'hello') msg = conn ...

  2. 小程序登陆遇到 ERR_REQUEST_PARAM

    小程序测试环境突然登陆不上,返回的错误信息是{}"code":-1,"error":"ERR_REQUEST_PARAM"}. 小程序登陆代 ...

  3. WebApi使用JWT认证(二)

    这是第二部:实现NetCore上的WebApi使用JWT认证 1.NetCore新建一个WebApi的项目 2.打开AppSettings.json,添加Jwt的信息,这里为了演示而已 { " ...

  4. Kail Linux渗透测试教程之网络扫描和嗅探工具Nmap

    Kail Linux渗透测试教程之网络扫描和嗅探工具Nmap 网络扫描和嗅探工具——Nmap Nmap也就网络映射器(Network Mapper),是一个免费开放的网络扫描和嗅探工具.该工具可以扫描 ...

  5. android 捕获所有异常 未捕获的异常

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 定义一个类 继承 应用, 实现 未捕获异常处理器 uncaughtExceptionHa ...

  6. [BZOJ4012][HNOI2015]开店(动态点分治,树链剖分)

    4012: [HNOI2015]开店 Time Limit: 70 Sec  Memory Limit: 512 MBSubmit: 2168  Solved: 947[Submit][Status] ...

  7. MongoDB,pymongo

    MongoDB: 数据库,nosql [{ id:1 name:"蔡文姬" age: 16 gender:"女" }, { id:1 name:"蔡文 ...

  8. 普及向 ZKW线段树!

    啊,是否疲倦了现在的线段树 太弱,还递归! 那我们就欢乐的学习另外一种神奇的线段树吧!(雾 他叫做zkw线段树   这个数据结构灰常好写(虽然线段树本身也特别好写……) 速度快(貌似只在单点更新方面比 ...

  9. hdu 4114 Disney's FastPass 状压dp

    Disney's FastPass Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  10. MYSQL学习笔记 (三)JOIN用法

    数据库的操作分开增删改查,其中查询操作基本占系统的90%,大家所说的优化SQL语句基本是优化查询语句.接下来将学习JOIN的用法,JOIN包括:INNER JOIN(内连接).LEFT JOIN(左外 ...