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.
→
sporto
November 26, 2013
Programming
210
1
Share
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
400
Rails with Webpack
sporto
1
240
Lesson learnt building Single Page Application
sporto
0
140
Safe Testing in Ruby
sporto
1
140
Go - A great language for building web applications
sporto
1
350
Other Decks in Programming
See All in Programming
ふつうのFeature Flag実践入門
irof
7
3.4k
CSC307 Lecture 17
javiergs
PRO
0
300
[KCD Czech] eBPF Meets the GPU: Future of AI Infra Observability
doniacld
0
130
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.2k
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
550
Talking to terminals (and how they talk back) (KotlinConf 2026)
jakewharton
PRO
1
170
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
2
300
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
390
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
11k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
2.4k
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
250
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
A Soul's Torment
seathinner
6
2.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
520
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
370
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
300
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
410
Thoughts on Productivity
jonyablonski
76
5.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
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