[Grunt] Minifying your output with grunt-uglify
For production we want to use minified javascript to reduce the payload that is sent from the server. This can easily be accomplished with grunt-uglify.
Install:
npm install grunt-contrib-uglify --save-dev
Example:
/**
* Created by Answer1215 on 11/16/2014.
*/
module.exports = function(grunt) {
grunt.initConfig({
stylus:{
compile:{
options: {
compress: false
},
files: {
"app/css/app.css": "styl/app.styl"
}
}
},
watch:{
stylus:{
files: ['styl/**/*.styl'],
tasks: ['stylus:compile']
},
css:{
options: {livereload: true},
files: ['app/css/**.css']
},
html:{
options: {livereload: true},
files: ['**.html']
},
script: {
options: {livereload: true},
files: ['app/js/**.js']
}
},
concat:{
options: {
separator: ';'
},
js:{
src: ['bower_components/angular/angular.min.js', 'app/js/app.js', 'app/js/**.js'],
dest: "build/app.js"
}
},
uglify: {
js: {
src: ["build/app.js"],
dest: "build/app.min.js"
}
}
}); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
}
Use:
grunt uglify
[Grunt] Minifying your output with grunt-uglify的更多相关文章
- grunt入门讲解1:grunt的基本概念和使用
Grunt和 Grunt 插件是通过 npm 安装并管理的,npm是 Node.js 的包管理器. Grunt 0.4.x 必须配合Node.js >= 0.8.0版本使用.老版本的 Node. ...
- 【grunt第三弹】grunt在前端实际项目中的应用
前言 [grunt第二弹]30分钟学会使用grunt打包前端代码(02) [grunt第一弹]30分钟学会使用grunt打包前端代码 经过前两次的学习,我们了解了grunt打包的一些基础知识,对于压缩 ...
- grunt之concat、cssmin、uglify
周末有点懒,跑去看了<智取威虎山>,手撕鬼子的神剧情节被徐老怪一条回忆线就解释过去了,牛到极致尽是这种四两拨千斤的处理方式,手撕加分,四星推荐. --------------------- ...
- grunt入门讲解6:grunt使用步骤和总结
Grunt是啥? 很火的前端自动化小工具,基于任务的命令行构建工具. Grunt能帮我们干啥? 假设有这样一个场景: 编码完成后,你需要做以下工作 HTML去掉注析.换行符 - HtmlMin CSS ...
- [Grunt] Development Automation Tasks with Grunt
With Grunt you can automate core tasks for your AngularJS project. In this lesson we will take a loo ...
- Grunt实战 --- 通过nodejs和Grunt实现项目在线构建
本文主要说明,实现在线自动构建项目的实现方法.
- grunt使用小记之uglify:最全的uglify使用DEMO
grunt-contrib-uglify uglify是一个文件压缩插件,项目地址:https://github.com/gruntjs/grunt-contrib-uglify 本文将以一个DEMO ...
- Grunt插件uglify
Gruntfile.js里面配置: module.exports = function(grunt){ // 项目配置 grunt.initConfig({ pkg: grunt.file.readJ ...
- 用grunt进行ES6转换,再用uglify压缩所有js实例
1.首先安装node.js 去官网下载exe执行文件安装即可,安装完成后自带有npm管理. 2.安装grunt CLI 在项目根文件夹下执行如下代码: npm install -g grunt-cli ...
随机推荐
- Jenkins多选项框使用
多选框的使用场景还是挺多的,比如发布多个服务,或者选择哪些服务器 想要使用多选项,则需要安装插件extend choice parameter,然后在项目中配置参数化构建过程 配置完上面,我们就可以在 ...
- PlayMaker GUI的Normalized
PlayMaker GUI的Normalized 在PlayMaker的GUI设置中,开发者可以通过Left.Top设置控件元素的起始点位置,通过Width.Height设置控件的大小.考虑到用户 ...
- Arduino可穿戴教程之第一个程序——Blink(一)
Arduino可穿戴教程之第一个程序——Blink(一) 至此我们的硬件和软件部分都准备好了,是时候测试一下他们是否可以和谐地合作了.当然,第一个程序我们并不需要自己来写,因为我们还没有了解过Ardu ...
- 【51Nod 1238】最小公倍数之和 V3
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1238 设\(A(n)=\sum\limits_{i=1}^n\frac{ ...
- logN判点是否在凸多边形内 HRBUSTOJ1429
就是利用叉积的性质,如果向量A1到向量A2是顺时针则叉积为负反之为正. 然后我们可以二分的判断找到一个点恰被两条射线夹在一起. 然后我们再判断是否l,r这两个点所连直线与点的关系. 具体资料可以参照这 ...
- [BZOJ5427]最长上升子序列
考虑O(n log n)的LIS求法,dp[i]表示到目前为止,长度为i的LIS的末尾最小是多少. 当当前数确定时直接用LIS的求法更新dp数组,当不确定时,由于这个数可以是任意数,所以可以接在任意上 ...
- input输入框限制输入英文,数字,汉字
<h1>js验证输入框内容</h1><br /><br /> 只能输入英文<input type="text" onkeyup ...
- HashSet,TreeSet和LinkedHashSet
Set接口 Set不允许包含相同的元素,如果试图把两个相同元素加入同一个集合中,add方法返回false. Set判断两个对象相同不是使用==运算符,而是根据equals方法.也就是说,只要两个对象用 ...
- VS2012项目中使用CocoStudio相关文件的设置
开发环境说明: win7 vs2012 coco2d-x 3.0 alpha1 cocos2d-x 3.0 alpha 1搭配CocoStudio使用,效果更佳.CocoStudio包含了游戏开发 ...
- HDU 4671 Backup Plan (2013多校7 1006题 构造)
Backup Plan Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...