[Grunt] Development Automation Tasks with Grunt
With Grunt you can automate core tasks for your AngularJS project. In this lesson we will take a look at converting Stylus files to CSS, and add a watch task to convert those files automatically whenever a change is detected.
We build a grunt for watch any styl file changes,
if changed, then we compile to css files, and see if the css files changed we reload the page.
Install:
npm install grunt --save-dev
npm install grunt-contrib-stylus
npm install grunt-contrib-watch
Example:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Grunt Stylus</title>
<link rel="stylesheet" href="app/css/app.css"/>
<script src="//localhost:35729/livereload.js"></script>
</head>
<body class="bg">
<h1>Grunt</h1>
<div>Here we are now!</div>
</body>
</html>
GruntFile:
/**
* 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']
}
}
}); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-stylus');
}

Read More:
https://github.com/gruntjs/grunt-contrib-stylus
https://github.com/gruntjs/grunt-contrib-watch#optionslivereload
https://egghead.io/lessons/development-automation-tasks
[Grunt] Development Automation Tasks with Grunt的更多相关文章
- 【grunt第三弹】grunt在前端实际项目中的应用
前言 [grunt第二弹]30分钟学会使用grunt打包前端代码(02) [grunt第一弹]30分钟学会使用grunt打包前端代码 经过前两次的学习,我们了解了grunt打包的一些基础知识,对于压缩 ...
- grunt入门讲解1:grunt的基本概念和使用
Grunt和 Grunt 插件是通过 npm 安装并管理的,npm是 Node.js 的包管理器. Grunt 0.4.x 必须配合Node.js >= 0.8.0版本使用.老版本的 Node. ...
- grunt入门讲解6:grunt使用步骤和总结
Grunt是啥? 很火的前端自动化小工具,基于任务的命令行构建工具. Grunt能帮我们干啥? 假设有这样一个场景: 编码完成后,你需要做以下工作 HTML去掉注析.换行符 - HtmlMin CSS ...
- Grunt实战 --- 通过nodejs和Grunt实现项目在线构建
本文主要说明,实现在线自动构建项目的实现方法.
- node & grunt path处理相关
在nodejs平台上写一些工具或者服务, 有很多需求会涉及到对目录或者文件路径的处理和操作.整理一些常用的处理path的方法 1.global __dirname Example: running n ...
- [Whole Web] [Node.js] [Browserify] [Grunt] Automation task with grunt-browserify & grunt-contrib-watch
What we want is when the server side Node.js files have been changed, we want to use browserify to b ...
- Grunt入门教程
引入:grunt是一套前端自动化工具,一个基于nodeJs的命令行工具,一般用于: ① 压缩文件 ② 合并文件 ③ 简单语法检查 环境:grunt是基于nodejs运行的,所以需要有nodejs,在N ...
- 基于Grunt构建一个JavaScript库
现在公认的JavaScript典型项目需要运行单元测试,合并压缩.有些还会使用代码生成器,代码样式检查或其他构建工具. Grunt.js是一个开源工具,可以帮助你完成上面的所有步骤.它非常容易扩展,并 ...
- 前端自动化grunt轻松入门
如果你还不了解grunt,或者只是听过它的名字而没有去研究过它,那么这篇入门级的文章就是为你写的,相信看完你就会爱上grunt! grunt是什么? grunt是一个非常好的自动化工具,你只管code ...
随机推荐
- socket的使用一
socket概念 socket层 理解socket Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口.在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协 ...
- BeautifulSoup解析库
解析库 解析器 使用方法 优势 劣势 Python标准库 BeautifulSoup(html, 'html.parser') 速度适中,容错能力强 老版本python容错能力差 lxml HTML解 ...
- 【BZOJ 4148】 4148: [AMPPZ2014]Pillars (乱搞)
4148: [AMPPZ2014]Pillars Time Limit: 5 Sec Memory Limit: 256 MBSec Special JudgeSubmit: 100 Solve ...
- manacher算法求最长回文子序列
一:背景 给定一个字符串,求出其最长回文子串.例如: s="abcd",最长回文长度为 1: s="ababa",最长回文长度为 5: s="abcc ...
- POJ3233 Matrix Power Series 矩阵乘法
http://poj.org/problem?id=3233 挺有意思的..学习到结构体作为变量的转移, 题意 : 给定矩阵A,求A + A^2 + A^3 + ... + A^k的结果(两个矩阵相加 ...
- Java高级架构师(一)第40节:更多模块的基本功能和配置
- 今天测试了一下 sqlalchemy 性能
self.db.query(Users).filter(Users.Id==1).first() < self.db.execute('SELECT * FROM `users` WHERE ...
- 使用sklearn进行交叉验证
模型评估方法 假如我们有一个带标签的数据集D,我们如何选择最优的模型? 衡量模型好坏的标准是看这个模型在新的数据集上面表现的如何,也就是看它的泛化误差.因为实际的数据没有标签,所以泛化误差是不可能直接 ...
- 线性稳压器 (LDO)
线性稳压器 (LDO) 当输出电压低于输入电压时,必须从负载电源和压降比来考虑要采用线性稳压器 (LDO) 或降压转换器 (Buck) 低压降线性稳压器 (LDO) 适合用在需求低噪讯.低电流和低压降 ...
- How to put a relative path for a DLL statically loaded?
How to put a relative path for a DLL statically loaded? I have a DLL made in Delphi 7/Windows XP tha ...