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
1
190
Grunt
sporto
November 26, 2013
Tweet
Share
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
190
Elm
sporto
1
270
Redux: Flux Reduced
sporto
1
370
Practically Immutable
sporto
0
200
Webpack and React
sporto
4
390
Rails with Webpack
sporto
1
230
Lesson learnt building Single Page Application
sporto
0
140
Safe Testing in Ruby
sporto
1
130
Go - A great language for building web applications
sporto
1
350
Other Decks in Programming
See All in Programming
Beyond the Basics: Signal Forms
manfredsteyer
PRO
0
110
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
200
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
480
AI活用のコスパを最大化する方法
ochtum
0
120
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
320
CSC307 Lecture 10
javiergs
PRO
1
690
AI巻き込み型コードレビューのススメ
nealle
2
2.5k
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1.1k
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
190
文字コードの話
qnighy
43
16k
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
2
180
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
8
2.3k
Featured
See All Featured
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
460
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
380
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.7k
Context Engineering - Making Every Token Count
addyosmani
9
730
Build your cross-platform service in a week with App Engine
jlugia
234
18k
GitHub's CSS Performance
jonrohan
1032
470k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4k
Balancing Empowerment & Direction
lara
5
930
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
210
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