Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Grunt
Search
sporto
November 26, 2013
Programming
220
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
300
Redux: Flux Reduced
sporto
1
390
Practically Immutable
sporto
0
220
Webpack and React
sporto
4
420
Rails with Webpack
sporto
1
250
Lesson learnt building Single Page Application
sporto
0
150
Safe Testing in Ruby
sporto
1
160
Go - A great language for building web applications
sporto
1
370
Other Decks in Programming
See All in Programming
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
430
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
290
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
460
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
150
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
iOSDCのペンライトを自動制御したい!
akkeylab
0
330
Webの地図
yosuke_furukawa
PRO
6
5k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
600
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
470
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
520
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.7k
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
720
The Curse of the Amulet
leimatthew05
3
15k
Designing for Timeless Needs
cassininazir
1
510
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
350
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Accessibility Awareness
sabderemane
1
230
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
Code Review Best Practice
trishagee
74
20k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
450
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
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