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. Java常用工具类之压缩解压

    package com.wazn.learn.util; import java.io.BufferedInputStream; import java.io.BufferedOutputStream ...

  2. 【洛谷比赛】[LnOI2019]长脖子鹿省选模拟赛 T1 题解

    今天是[LnOI2019]长脖子鹿省选模拟赛的时间,小编表示考的不怎么样,改了半天也只会改第一题,那也先呈上题解吧. T1:P5248 [LnOI2019SP]快速多项式变换(FPT) 一看这题就很手 ...

  3. hdu 2433 Travel(还不会)

    Problem Description       One day, Tom traveled to a country named BGM. BGM is a small country, but ...

  4. Codeforces 839E Mother of Dragons(极大团)

    [题目链接] http://codeforces.com/contest/839/problem/E [题目大意] 现在有一些点,现在你有k的液体,随意分配给这些点, 当两个点有边相连的时候,他们能产 ...

  5. apose 根据excel 导出模版

    string file = Server.MapPath("~/Excel/ZWxxtj.xls");            DataSet ds = new DataSet(); ...

  6. linux基础命令学习(四)用户与群组

    一.linux用户账号的管理 linux用户账号的管理主要包括用户添加.用户删除.用户修改. 添加用户账号就是在系统创建一个新账号,然后为新账号分为用户号.用户组.主目录和登录Shell等资源. 刚添 ...

  7. java - 内存泄漏

    内存泄漏问题产生原因 长生命周期的对象持有短生命周期对象的引用就很可能发生内存泄露,尽管短生命周期对象已经不再需要,但是因为长生命周期对象持有它的引用而导致不能被回收,这就是java中内存泄露的发生场 ...

  8. slf4j使用

    pom jar包引用<!-- Logging --> <dependency> <groupId>ch.qos.logback</groupId> &l ...

  9. How to make a combo box with fulltext search autocomplete support?

    I would like a user to be able to type in the second or third word from a TComboBoxitem and for that ...

  10. Python中用MacFSEvents模块监视MacOS文件系统改变一例

    最近一个项目中用gulp-watch不能满足需求,于是想到了用Python来解决问题.在安装了MacFSEvents模块后,写了下面一个小程序. #!/usr/bin/env python2 #-*- ...