[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 ...
随机推荐
- Markdown 实现首行缩进
把输入法由半角改为全角. 两次空格之后就能够有两个汉字的缩进. 在开头的时候,先输入这个,然后紧跟着输入文本即可.分号也不要掉.
- 洛谷——P1330 封锁阳光大学
P1330 封锁阳光大学 题目描述 曹是一只爱刷街的老曹,暑假期间,他每天都欢快地在阳光大学的校园里刷街.河蟹看到欢快的曹,感到不爽.河蟹决定封锁阳光大学,不让曹刷街. 阳光大学的校园是一张由N个点构 ...
- 在树莓派3B上安装node.js
本文主讲如何在树莓派3B上安装node.js 环境描述1. 树莓派安装了`2016-11-25-raspbian-jessie-lite`(PS:在此版本的镜像中,默认禁用了ssh,在烧录好镜像之后, ...
- 【BZOJ 4596】 4596: [Shoi2016]黑暗前的幻想乡 (容斥原理+矩阵树定理)
4596: [Shoi2016]黑暗前的幻想乡 Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 324 Solved: 187 Description ...
- 【BZOJ 1221】 1221: [HNOI2001] 软件开发 (最小费用流)
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1581 Solved: 891 Description ...
- android remoteView
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha remoteView 可以在 appWidget 和 notification 中 使 ...
- codevs 1392 合并傻子
1392 合并傻子 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 在一个园形操场的四周站着N个傻子,现要将傻子有 ...
- 在活动中使用菜单(Menu)
任务名称:在活动使用菜单 任务现象:打开程序后,点击菜单按钮会出现2个选项,点击选项时会跳出相对应的提示框 步骤 1.创建一个项目,详细参考:http://8c925c9a.wiz03.com/sha ...
- bzoj 1026
很久以前做过的一道数位DP,现在用一种新的解决数位DP的比较一般的方法. 数位DP裸题是:求[L,R]有多少个数. 先转化成求[0,R]有多少个数,然后区间相减即可. 对于[0,R]中的所有数,用0补 ...
- 通过wifi上网,桥接模式下virtualBox虚拟机无法连上网的解决办法
https://jingyan.baidu.com/article/948f59242e601dd80ff5f929.html