我的grunt配置
module.exports = function(grunt) { // 配置.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
css: {
files: 'static/introduce/scss/**/*.scss',
tasks: ['clean:css','compass'],
options: {
livereload: true
}
} ,
includereplace:{
files:'src/html/**/*.html',
tasks:['includereplace','copy:html','clean:html']
} },
jshint:{//js代码检测工具
options: {
jshintrc: '.jshintrc'
},
src: ["src/static/introduce/js/app/**/*.js"]
},
includereplace: {//包含html片段
nav: {
files: [
{src: 'src/html/**/*.html', dest: '.tmphtml/'}
]
}
},
uglify: {//js压缩
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
js: {
files: [{
expand: true,
cwd: 'static/introduce/js',
src: '**/*.js',
dest: 'static/introduce/js',
ext:".min.js"
}]
}
},
compass: {//compass
dev: {
options: {
sassDir: 'static/introduce/scss',
cssDir: 'static/introduce/css',
outputStyle:'compressed',
noLineComments: true
}
}
},
clean: {//清除
mod:["static/introduce/css/module"],
css:["static/introduce/css"],
html:[".tmphtml/"]
},
copy: {//复制
css: {
expand: true,
cwd: 'static/introduce/css/',
src: '**',
dest: '../../src/SVipSys/SVipSys.Web/static/Introduce/css',
flatten: true,
filter: 'isFile'
},
scss:{
expand: true,
cwd: 'static/introduce/scss/',
src: '**',
dest: '../../src/SVipSys/SVipSys.Web/static/Introduce/scss'
},
html:{
expand: true,
cwd: '.tmphtml/src/html/',
src: '**',
dest: 'view/'
}
},
imagemin:{//图片压缩
dynamic: {
files: [{
expand: true,
cwd: 'static/',
src: ['**/*.{png,jpg,gif}'],
dest: 'static/'
}]
}
}
}); // 加载任务
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-include-replace');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-imagemin'); // 任务列表
grunt.registerTask('default',['clean:css','compass','clean:mod',,'watch']);
grunt.registerTask('tpl',['includereplace','copy:html','clean:html']); };
写在后面的话,最初听到grunt这个词的时候,是在去年上半年,当时前端构建工具非常火,我一直觉得它是一个非常高大上的东西,后来发现真的只是个工具而已。大神们说,你们不应该被工具所累,因为工具是学不完的。是的,我们不需要跟风,但不代表不必要用。很多是项目需求,比如你在入职后接手了一些新的项目,那么,最好就是学习它,掌握它。使用grunt的时候,确实感到了方便之处,比如图片压缩、js压缩、代码检测。。。工具,它是帮我们干活,减少重复、无聊的工作量的。所以,使用它的时候,我们应该明确的知道,希望它能帮我们干什么活,而不是对着API写一堆配置都不知道在干嘛。。。
我的grunt配置的更多相关文章
- grunt配置任务
这个指南解释了如何使用 Gruntfile 来为你的项目配置task.如果你还不知道 Gruntfile 是什么,请先阅读 快速入门 指南并看看这个Gruntfile 实例. Grunt配置 Grun ...
- Nodejs+Grunt配置SASS项目自动编译
Nodejs+Grunt配置SASS项目自动编译 早前听说Nodejs和Grunt很强大,特别是用来构建自动化的前端开发,更是强大无比.但一直碍于自己掌握的技术有限,不敢深入,也未曾深入下去.最近在开 ...
- grunt配置详情
这个grunt配置 是我的一个程序员朋友从网上无意间看到的,然后他亲测了下,恩,是可以的.不过我到目前还未测试过是否可以. 一.安装node, 首先确保电脑已有node的环境.然后 运行 npm i ...
- grunt配置太复杂?发布一个前端构建工具,简单高效,自动跳过未更新的文件
做前端项目,如果没有一个自动化构建工具,手动处理那简直就是坑爹O(∩_∩)O.于是上网了解了下,grunt用的人不少,功能也挺强大.看了一下grunt的配置(包括gulp),感觉稍显复杂.当时项目结构 ...
- grunt配置太复杂?使用Qbuild进行文件合并、压缩、格式化等处理
上次简单介绍了下Qbuild的特点和配置,其实实现一个自动化工具并不复杂,往简单里说,无非就是筛选文件和处理文件.但Qbuild的源码也并不少,还是做了不少工作的. 1. 引入了插件机制.在Qbuil ...
- grunt配置sass项目自动编译
1.安装Ruby和SASS 首先我们需要在电脑上安装Ruby和SASS.如果您使用的是Mac,您就没必要安装Ruby.如果您使用的是Window系统,你需要安装Ruby. 2.安装Nodejs 由于使 ...
- 配置grunt进行css、js的检查、合并和压缩
现在会进行代码的合并和压缩已成为前端人员的必备知识,那么现在来介绍一个grunt的工具.grunt是个风靡世界的工具,它的首页是 http://www.gruntjs.net 这是个中文网站,有文档 ...
- grunt安装、配置、在webstrom中使用
1.全局范围安装 Grunt命令行(CLI) npm install -g grunt-cli Grunt CLI的任务很简单:调用与Gruntfile在同一目录中 Grunt.这样带来的好处是,允许 ...
- grunt项目配置
安装完CLI,还要在项目安装Grunt npm install -g grunt-cli npm install grunt --save-dev 源码放在src下 package.json放在根目录 ...
随机推荐
- JavaUtil_03_图片处理工具类
一.源码 功能:缩放图像.切割图像.图像类型转换.彩色转黑白.文字水印.图片水印等 package com.ray.dingtalk.util; import java.awt.AlphaCompos ...
- 书写优雅的shell脚本(八)- 日期格式化
1. 将日期格式转为时间戳 获取当前时间:currenttime=`date "+%Y-%m-%d %H:%M:%S"` 结果:2015-04-13 11:15:43 将当前时间转 ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Qt容器组件(二)之QWidgetStack、QMdiArea、QDockWidget
QT中有九种容器组件,分别是组合框QGroupBox.滚动区QScrollArea.工具箱QToolBox.选项卡QTabWidget.控件栈QWidgetStack.框架QFrame.组件QWidg ...
- ACM学习历程—HDU1392 Surround the Trees(计算几何)
Description There are a lot of trees in an area. A peasant wants to buy a rope to surround all these ...
- ACM学习历程——POJ3468 A Simple Problem with Integers(线段树)
Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. On ...
- 洛谷 P2919 [USACO08NOV]守护农场Guarding the Farm
题目描述 The farm has many hills upon which Farmer John would like to place guards to ensure the safety ...
- Struts2+JQuery+Json登陆实例
Struts2+JQuery+Json登陆实例 博客分类: Struts2 在搭建之前.. 首先,需要准备struts2.0框架的5个核心包, 以及jsonplugin-0.32.jar 以及js ...
- <c和指针>学习笔记4之字符串
1 字符串基础 NUL字节是字符串的终止符,但它本身并不是字符串的一部分,所以字符串的长度并不包括NUL字节. (1)字符串长度 size_t strlen(char const * string)注 ...
- 微信小程序开发之日期组件
一: wxml: <view class="navbarlift" style="background:#ffffff;padding:20rpx"> ...