Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Grunt
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
lylijincheng
August 10, 2013
Technology
140
1
Share
Grunt
Introduction to grunt.js
lylijincheng
August 10, 2013
More Decks by lylijincheng
See All by lylijincheng
Nodejs getting-started
lylijincheng
1
170
Other Decks in Technology
See All in Technology
React、まだ楽しくて草
uhyo
7
3.7k
Generative UI × A2UI で AI エージェントを作った話 AI-DLC も使ってみた!
kmiya84377
1
300
Databricks における 生成AIガバナンスの実践
taka_aki
1
120
Claude Codeですべての日常業務を爆速化しよう!
minorun365
PRO
17
16k
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
160
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
2
530
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
Unlocking the Apps
pimterry
0
150
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
200
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
160
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
6
2.6k
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
450
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
GitHub's CSS Performance
jonrohan
1033
470k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
Fireside Chat
paigeccino
42
3.9k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
The Curious Case for Waylosing
cassininazir
1
370
Building an army of robots
kneath
306
46k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
300
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
210
Transcript
Grunt 基于任务的命令行构建工具
开始 发音:[ɡrʌnt] 网站:http://gruntjs.com/ Github:https://github.com/gruntjs Wiki: https://github.com/gruntjs/grunt/wiki/Getting-started 使用:jQuery, bootstrap, yui, pure
…
任务 • JSHint 检测代码质量 • Concat 合并 • Copy 复制
• Minify 压缩 • Qunit 单元测试 • Source map 调试
准备 • Nodejs • NPM
安装 • the CLI • grunt-init • grunt-plugins • templates
安装全局命令 > npm install –g grunt-cli 作用:执行Grunt任务 将grunt命令添加到PATH路径,在任何目录都可运行。
安装 grunt-init > npm install –g grunt-init 作用:通过使用模板使项目创建实现自动化
安装插件 > npm install grunt-contrib-jshint --save-dev > npm install grunt-contrib-qunit
--save-dev > npm install grunt-contrib-concat --save-dev > npm install grunt-contrib-uglify --save-dev > npm install grunt-contrib-watch --save-dev
安装模板 模板会依赖当前环境或使用一些提问来建立整个项目的目录结构 可以使用现有的模板或自定义模板 grunt-init-gruntfile, grunt-init-gruntplugin. 使用模板创建Grunt项目 > grunt-init [template] 模板存放在
home 目录的 .grunt-init 文件夹下,可以使用git来安装 > git clone https://github.com/gruntjs/grunt-init-gruntfile.git ~/.grunt-init/gruntfile
准备一个新项目 在项目根目录下创建两个文件 • Gruntfile Gruntfile.js 或者 Gruntfile.coffee • Package.json
Gruntfile > grunt-init gruntfile • 配置或定义任务 • 加载Grunt插件
Gruntfile 结构 Gruntfile一般包括以下部分: • 外层包装函数 module.exports = function(grunt) {}; •
项目和任务配置 grunt.initConfig(/* config */) • 加载插件和任务 grunt.loadNpmTasks(/* plugins */) • 自定义任务 grunt.registerTask(/* default tasks */)
package.json > npm init • 存放项目信息,作为NPM模块发布 • 被Gruntfile依赖,读取项目有关配置和信息
使用Grunt • 切换至项目根目录 > cd • 安装依赖 > npm install
• 运行Grunt > grunt
</thanks>