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. Am335x u-boot 启动过程中的系统频率配置

    Am335x的时钟结构分为:ADPLLS和ADPLLLJ 1.ADPLLS用来配置Core_CLK,Dispaly_clk,ARM系统CLK(mpu_clk),DDR PLLs_clk 2.ADPLL ...

  2. Linux下C语言多文件的编译以及makefile的应用

    1.关于编译和链接 一般来说,无论是C.C++,首先要把源文件编译成中间代码文件,在Windows下也就是.obj文件,UNIX下是.o文件,即Object File,这个动作叫做编译(compile ...

  3. 埃及分数 a* 搜索 知识点mark

    题意 在古埃及,人们使用单位分数的和(即1/a,a是自然数)表示一切有理 数. 例如,2/3=1/2+1/6,但不允许2/3=1/3+1/3,因为在加数中不允许有相同的. 对于一个分数a/b,表示方法 ...

  4. 【最大独立集】BZOJ3175- [Tjoi2013]攻击装置

    [题目大意] 给定一个01矩阵,其中你可以在0的位置放置攻击装置.每一个攻击装置(x,y)都可以按照“日”字攻击其周围的 8个位置(x-1,y-2),(x-2,y-1),(x+1,y-2),(x+2, ...

  5. Codeforces Round #303 (Div. 2) C. Woodcutters 贪心

    C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/probl ...

  6. Shell基础学习(四) echo命令

    1.显示普通的字符串 echo "boring" 2.显示转义字符 echo "\"It is a test!\""; 3.read 命令从 ...

  7. shell 快速移动,快捷操作

    ctr+h 往后删除一字符 ctr+d 往前删除一字符 ctr+b 光标往前 ctr+f 往后ctr+u 删除到最前 ctr+K删除到最后ctr+a 光标到最前 ctr+e 光标到最后ctr+p 往上 ...

  8. Spring工具类ToStringBuilder用法简介

    比如说我们需要打印某个方法的User参数对象 package test; /** * * @author zhengtian * @time 2012-6-28 */ public class Use ...

  9. Upgrading Directly from MySQL 5.0 to 5.7 using an ‘In Place’ Upgrade

    http://mysqlserverteam.com/upgrading-directly-from-mysql-5-0-to-5-7-using-an-in-place-upgrade/

  10. 别闹了,你还在记密码? | 1password 备忘&教程

    每个人在网上或电脑离线软件上都会有一些账号和密码. 这些账号,如果你设置成一个呢,不安全,尤其是如果你很多地方的账号密码都是同一套的话,如果在一个安全系数比较低的地方被盗号了,那其他地方也瞬间都不安全 ...