☀【Grunt】插件
Grunt Plugins
http://gruntjs.com/plugins
grunt-contrib-sass
sass: {
compile: {
files: {
'css/core.css': ['css/core.scss']
}
}
}

grunt-contrib-cssmin #CSS压缩
cssmin: {
combine: {
files: {
'css/core-min.css': ['css/core.css']
}
}
}
cssmin: {
with_banner: {
options: {
banner: '/* projA Css files by Sonic */'
},
files: {
'dist/css/combo.css': ['src/css/base.css','src/css/index.css']
}
}
}
grunt-contrib-uglify #JS压缩
uglify: { // jsmin
options: {
mangle: false
},
build: {
files: {
'dist/js/comm.js': ['src/js/comm.js']
}
}
},
grunt-contrib-imagemin #图片压缩
imagemin: {
dist: {
options: {
optimizationLevel: 3
},
files: {
'dist/images/photo.png': 'src/images/photo.png',
'dist/images/badge.jpg': 'src/images/badge.jpg'
}
}
}
imagemin: {
dist: {
options: {
optimizationLevel: 3 //定义 PNG 图片优化水平
},
files: [{
expand: true,
cwd: 'img/',
src: ['**/*.{png,jpg,jpeg}'], // 优化 img 目录下所有 png/jpg/jpeg 图片
dest: 'img/' // 优化后的图片保存位置,覆盖旧图片,并且不作提示
}]
}
}
grunt-contrib-csslint #CSS校验
csslint: {
options: {
formatters: [
{id: 'junit-xml', dest: 'public/stylesheets/csslint_junit.xml'},
{id: 'csslint-xml', dest: 'public/stylesheets/csslint.xml'}
]
},
strict: {
options: {
import: 2
},
src: ['public/stylesheets/common.css']
}
}
grunt --force
grunt-contrib-jshint #JS校验
https://github.com/gruntjs/grunt-contrib-jshint
options: {
'-W085': true, // ignore: Don't use 'with'
'-W004': true, // ignore: 'xxx' is already defined
'-W116': true, // ignore: Expected '===' and instead saw '=='
'-W033': true, // ignore: Missing semicolon
//'-W032': true, // ignore: unnecessary semicolon
//'-W038': true // ignore: 'xxx' used out of scope
}
function f(n) { // W004 'n' is already defined
var n;
}
grunt-contrib-watch
watch: {
scripts: {
files: ['assets/css/*.less'],
tasks: ['less']
}
}
grunt-contrib-htmlmin
htmlmin: {
dist: {
options: {
removeComments: true, // 去注析
collapseWhitespace: true // 去换行
},
files: {
'dist/html/index.html': ['src/html/index.html']
}
}
}
grunt-contrib-compass
compass: { // compass任务
dist: { // 一个子任务
options: { // 任务的设置
sassDir: 'sass',
cssDir: 'css',
environment: 'production'
}
},
dev: { // 另一个子任务
options: {
sassDir: 'sass',
cssDir: 'style'
}
}
}
grunt-contrib-concat #合并
pkg: grunt.file.readJSON('package.json'),
concat: {
options: { //配置
stripBanners: true,
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + //添加自定义的banner
'<%= grunt.template.today("yyyy-mm-dd") %> */'
},
dist: { //任务
src: ['src/intro.js', 'src/project.js', 'src/outro.js'], //源目录文件
dest: 'dist/built.js' //合并后的文件
},
basic_and_extras: { //另一个任务
files: { //另一种更简便的写法
'dist/basic.js': ['src/main.js'],
'dist/with_extras.js': ['src/main.js', 'src/extras.js']
}
}
}
grunt-contrib-copy
copy: {
main: {
files: [
{src: 'index.html', dest: 'dest/index.html'},
{src: ['assets/images/**'], dest: 'dest/'},
{src: ['assets/css/app.min.css'], dest: 'dest/'},
{src: ['assets/js/lib/libs.min.js'], dest: 'dest/'},
{src: ['assets/js/app.min.js'], dest: 'dest/'}
]
}
}
grunt-contrib-less
less: { // 任务task 固定命名
// 编译
compile: { // 目标target 随意命名
files: { // 文件files 固定命名
'assets/css/main.css': 'assets/css/main.less' // dest src
}
},
// 压缩
yuicompress: {
files: {
'assets/css/main-min.css': 'assets/css/main.css'
},
options: { // 选项options
yuicompress: true
}
}
}
less: {
dist: {
files: {
'assets/css/main-min.css': ['assets/css/base.less', 'assets/css/main.less']
},
options: {
yuicompress: true
}
}
}
grunt-contrib-connect
为文件建立站点,实现通过浏览器访问文件的功能
http://localhost:9001/src/html/index.html

grunt-regarde
监控哪些文件发生变化,当变化发生时,执行设定的任务
grunt-contrib-livereload
建立web socket服务器,让页面同web socket通行
☀【Grunt】插件的更多相关文章
- 快速开发Grunt插件----压缩js模板
前言 Grunt是一款前端构建工具,帮助我们自动化搭建前端工程.它可以实现自动对js.css.html文件的合并.压缩等一些列操作.Grunt有很多插件,每一款插件实现某个功能,你可以通过npm命名去 ...
- node.js安装及grunt插件,如何进行脚本压缩
http://gruntjs.com/pluginshttp://gruntjs.com/getting-startedhttp://gruntjs.com/configuring-tasks#glo ...
- Grunt 插件使用汇总
最近使用了很多 Grunt 插件,这里把使用 Grunt 中涉及的从开发.代码检查.单元测试.E2E 测试,直到发布所涉及的插件,做一个比较完全的汇总. 环境搭建 1. 创建 Web 前端开发环境 2 ...
- 如何开发 Grunt 插件
创建 grunt 插件 准备工作:(node/npm/git 安装,在此不做赘述) yeoman generator 可以自动生成一个插件模板. 安装 yo npm install -g yo 安装 ...
- 详解Grunt插件之LiveReload实现页面自动刷新(两种方案)
http://www.jb51.net/article/70415.htm 含Grunt系列教程 这篇文章主要通过两种方案详解Grunt插件之LiveReload实现页面自动刷新,需要的朋友可以 ...
- grunt 插件
一个简单的 grunt 插件, 作用是 把 css 文件中的 /images/ 替换成指定的 url path, 以实现 图片 cdn 路劲改造 插件项目文件结构 grunt-contrib-s ...
- chrome下的Grunt插件断点调试——基于node-inspector
之前调试grunt插件时,都是通过人肉打log来调试.不仅效率低,而且会产生一堆无用的代码.于是简单google了下node断点调试的方法,总结了下. 借助node-inspector,我们可以通过C ...
- [转载]Grunt插件之LiveReload 实现页面自动刷新,所见即所得编辑
配置文件下载 http://vdisk.weibo.com/s/DOlfks4wpIj LiveReload安装前的准备工作: 安装Node.js和Grunt,如果第一次接触,可以参考:Window ...
- 使用Grunt 插件打包Electron Windows应用
最近利用Electron来创建跨桌面应用的趋势似乎很火.看了几个用Electron开发的应用,这些应用在windows下面的安装方式,都是类似一个绿色软件的安装方法,下载.zip->解压到相应目 ...
- grunt插件[font-spider] : 转码,压缩字体 @font-face
字蛛插件:压缩与转码静态页面中的 WebFont 需要注意的是,目前只支持 grunt@0.4.1 package.json { "name": "fontS" ...
随机推荐
- linux 输入子系统(1)----系统概述
输入设备的工作中,只是中断.读键值/坐标值是设备相关的,而输入事件的缓冲区管理以及字符设备驱动的file_operations接口则对输入设备是通用的,基于此,内核设计了input输入子系统,由核心层 ...
- WPF后台更换背景图-Background
Uri uri = new Uri("Images/BACK.gif", UriKind.Relative);BitmapImage bimg = new BitmapImage( ...
- 【WPF】Application应用程序启动
wpf应用程序在启动的时候会自动创建Main函数并调用Application实例的run(),从而启动Application进程.Main函数在一个App.g.cs文件中,App.g.cs文件的位置在 ...
- C语言字符串与字符数组
字符串儿与字符数组 字符数组的定义: Char buffer[]; 字符数组初始化: Char buffer1[]="hello world"; 利用scanf输入一个字符串儿 代 ...
- 2014年辛星完全解读Javascript第七节 数组和对象
由于Javascript是脚本语言,因此,使用起来非常方便,数组的使用也是比较简单的,下面我们就主要介绍一下Javascript中数组的介绍,以及上一节中没有完成的对象的介绍. *********** ...
- jQuery ajax 实现分页 kkpager插件
代码片段一: <!--分页组件 JS CSS 开始--> <!--分页组件 CSS--> <link type="text/css" href=&qu ...
- XSS前端防火墙
前一段时间,在EtherDream大神的博客里看到关于XSS防火墙的一系列文章,觉得很有意思.刚好科创要做一个防火墙,就把XSS前端防火墙作为一个创新点,着手去实现了. 在实现过程中,由于各种原因,比 ...
- html template
https://wrapbootstrap.com/tag/single-page http://themeforest.net/ https://wrapbootstrap.com/themes h ...
- MyBatis定义复合主键
<resultMap type="XX" id="XXMap"> <id property="id" column=& ...
- 无锁算法CAS 概述
无锁算法CAS 概述 JDK5.0以后的版本都引入了高级并发特性,大多数的特性在java.util.concurrent包中,是专门用于多线并发编程的,充分利用了现代多处理器和多核心系统的功能以编写大 ...