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
sporto
November 26, 2013
Programming
210
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Grunt
sporto
November 26, 2013
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
200
Elm
sporto
1
290
Redux: Flux Reduced
sporto
1
380
Practically Immutable
sporto
0
210
Webpack and React
sporto
4
410
Rails with Webpack
sporto
1
240
Lesson learnt building Single Page Application
sporto
0
150
Safe Testing in Ruby
sporto
1
150
Go - A great language for building web applications
sporto
1
350
Other Decks in Programming
See All in Programming
RTSPクライアントを自作してみた話
simotin13
0
620
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
190
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.3k
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
370
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
7k
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
180
A2UI という光を覗いてみる
satohjohn
1
140
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
1B+ /day規模のログを管理する技術
broadleaf
0
100
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.2k
Webフレームワークの ベンチマークについて
yusukebe
0
170
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
210
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
210
KATA
mclloyd
PRO
35
15k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
320
Technical Leadership for Architectural Decision Making
baasie
3
420
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
The Spectacular Lies of Maps
axbom
PRO
1
820
Embracing the Ebb and Flow
colly
88
5.1k
Transcript
Grunt @sebasporto
WHAT? Task runner (like make, rake)
WHY? Cross platform Lots of plug-ins Nice logging Is JS
Is Node
WHY NOT? Verbose Could end as an unmaintainable complex tangle
mess of configuration
Main uses Build system Live reload Daemons Automated tasks Whatever
Common plug-ins Lint Minify Concat Test (Mocha, Jasmine) Optimise images
Installing grunt Install grunt cli as global Install grunt as
local Uses package.json to keep track of dependencies (devDependecies)
Gruntfile module.exports = function(grunt) { ! grunt.initConfig({ uglify: { build:
{ src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } } }); ! grunt.loadNpmTasks('grunt-contrib-uglify'); ! grunt.registerTask('default', ['uglify']); }; tasks config loading and registering tasks
A basic task grunt.registerTask('foo', 'A task', function(arg1, arg2) { …
}); $ grunt foo arg1 arg2
Just Node var foo = require(‘foo’); ! grunt.registerTask('foo', 'A task',
function(arg1, arg2) { // You can do whatever you can with Node ! foo.doSomething(); });
A multitask grunt.registerMultiTask('foo', 'A task', function() { … }); grunt.initConfig({
foo: { dev: {…}, prod: {…} } });
Multitasks $ grunt foo grunt.initConfig({ foo: { dev: {…}, prod:
{…} } }); runs dev and prod
Multitasks $ grunt foo:dev grunt.initConfig({ foo: { dev: {…}, prod:
{…} } }); runs dev only
Chaining tasks grunt.registerTask(‘all', [‘jshint’, ‘mocha’, ‘concat’]); $ grunt all
Chaining tasks grunt.registerTask('all', 'A task', function() { grunt.task.run(‘jshint’, ‘concat’); grunt.task.run(‘ngmin’);
}); $ grunt all
Async tasks grunt.registerTask('all', 'A task', function() { var done =
this.async(); ! doSomethingAsync(done); }); $ grunt all
Events grunt.event.on(‘foo:started’, handler); ! grunt.event.emit(‘foo:stated’, args…);
Installing a plug-in $ npm install grunt-goserver --save-dev grunt.loadNpmTasks(‘grunt-goserver'); !
grunt.initConfig({ goserver: { default: { srcPath: '/full/path/to/src/folder', … }, }, }) In Gruntfile.js
Creating a plug-in Install grunt-init module Clone template Run generator
Code npm publish
Plug-in best practices Create an NPM module first Wrap that
module in a Grunt plug-in
Thanks @sebasporto