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
Automating your workflow with Grunt
Search
Dimitris Tsironis
December 20, 2013
Technology
200
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Automating your workflow with Grunt
Dimitris Tsironis
December 20, 2013
More Decks by Dimitris Tsironis
See All by Dimitris Tsironis
Introduction to Digigov SDK
tsironis
0
65
How to Develop Backbone Plugins (...for the greater good!)
tsironis
0
290
Modern Webapps
tsironis
1
110
Git 201
tsironis
0
200
Git 101
tsironis
0
230
Capistrano for non-Rubyists
tsironis
4
150
HTML+CSS: how to get started
tsironis
1
89
Coffeescript: unfancy javascript
tsironis
2
500
Coffescript - take a sip of code
tsironis
4
180
Other Decks in Technology
See All in Technology
【Claude Code】鹿野さんに聞く 私の推しの並行開発環境 大公開 / claude-code-parallel-2026-07-15
tonkotsuboy_com
12
8.5k
SRE本の知られざる名シーン / The Hidden Gems of Google SRE Book
nari_ex
1
420
Compose 新機能総まとめ / What's New in Jetpack Compose
yanzm
0
310
個人開発で育てる「大規模設計の苗床」 - AI時代の1人開発から始める業務への知識接続 / The Seedbed for Large-Scale Design - From AI-Era Solo Projects to Professional Knowledge
bitkey
PRO
1
270
Terraform共通モジュールをチーム横断で“変えられる”運用へ ― リリースと適用の分離
kekke_n
1
3.3k
ruby.wasmとPicoRuby.wasmに対応した仮想DOMライブラリを作ってる話 #kaigieffect_kaigi
sue445
PRO
0
150
AIコード生成×サプライチェーン攻撃 — PHPが直面する“二重の信頼問題
shinyasaita
0
170
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
2
130
生成AI×AWS CDK×AWS FISで"振り返れる"ミニGameDayをつくろう
yoshimi0227
1
280
実践!既存 Project への AI-Driven Development 適用〜 一ヶ月で Project 唯一のフロントエンドエンジニアを作り出せ〜
lycorptech_jp
PRO
0
140
しぶいSRE: サーバから見えない障害にどう向き合うか。ラストワンマイルのデバッグ実践 / Shibui SRE
kanny
13
6.4k
SRE Next 2026 何でも屋からの脱却
bto
0
880
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.5k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
520
Rails Girls Zürich Keynote
gr2m
96
14k
Odyssey Design
rkendrick25
PRO
2
730
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
330
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Code Reviewing Like a Champion
maltzj
528
40k
Designing Powerful Visuals for Engaging Learning
tmiket
1
450
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Technical Leadership for Architectural Decision Making
baasie
3
440
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
380
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
Transcript
Automate your front-end workflow with grunt.js
About this This talk is about workflow patterns using Grunt
reinvent your work, love JS more make your life easier
Who Dimitris Tsironis Front-end Engineer at Splunk (ex-Bugsense) ! passionate
about bringing BigData to the masses, eating bacon & geeing around
First, a story from good ol’ days
<a href="javascript:void(0)" onclick=“myJsFunc();”> Run JavaScript Code!!!!11! </a> First
<a href="javascript:void(0)" onclick=“myJsFunc();”> Run JavaScript Code!!!!11! </a> First
Now
Now
None
None
None
*cough* *cough*
Problem typical js file, named stuff.js
grunt is a task-based command line build tool for JavaScript
projects
Grunt.js is used for Concatenation Testing with headless browsers JS
linting basically, whatever
Installation $ npm install -g grunt-cli Install the grunt cli
tool
Installation Edit your package.json file { "name": "my-project-name", "version": "0.1.0",
"devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.3" } } grunt.loadNpmTasks(‘grunt-contrib-uglify'); Then in your Gruntfile.js add
Gruntfile.js module.exports = function(grunt) { ! // Project configuration. grunt.initConfig({
pkg: grunt.file.readJSON('package.json'), uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' }, build: { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } } }); ! // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks('grunt-contrib-uglify'); ! // Default task(s). grunt.registerTask('default', ['uglify']); ! };
Concatenating module: grunt-contrib-concat concat: { ‘assets/js/main.js’: [ ‘js/libs/jquery.js’, ‘js/libs/underscore.js’ ‘js/libs/backbone.js,
‘js/src/app.js’], ‘assets/css/style.css’: [ ‘css/bootstrap.css’, ‘css/main.css’] }
Compiling LESS module: grunt-contrib-less less: { dashboard: { files: {
"css/main.css": "less/style.less", "css/landing.css": "less/landing.less", } } }
Running specs #1 module: grunt-contrib-jasmine jasmine: { src: [ 'specs/project.js'],
options: { host: 'http://localhost:7000/', vendor: [ ‘libs/jquery.js’], helpers: [ 'specs/jasmine-jquery/lib/jasmine-jquery.js', ‘specs/bower_components/sinonjs/sinon.js' ], template: 'specs/index.tmpl', specs: 'specs/build/specs.js', keepRunner: true } },
Running specs #2 module: grunt-contrib-connect connect: { server: { options:
{ port: 7000 } } } grunt.registerTask('specs', ['connect', 'jasmine']); Registering our custom “specs” tasks
Watching files module: grunt-contrib-watch watch: { gruntfile: { files: '<%=
jshint.gruntfile.src %>', tasks: ['jshint:gruntfile', 'concat', 'less'] }, less: { files: “less/**/*.less”, /* or use an array */ tasks: [‘less’, ‘concat’] }, specs: { files: “specs/**/*Specs.js” tasks: [‘specs’] } }
Live reload module: grunt-reload reload: { port: 6001, proxy: {
host: 'localhost' } }, watch: { less: { files: “less/**/*.less”, /* or use an array */ tasks: [‘less’, ‘concat’, ‘reload’] } }
bower a package manager for the web
Installation $ npm install -g bower Install the bower tool
Usage $ bower install <package> Install the bower tool $
bower install <package>#<version> or just install dependencies from bower.json $ bower install
Search $ bower search <search-term> Search the packages
/etc/ $ bower help Help is always provided
Defining a new package $ bower init { "name": "my-project",
"version": "1.0.0", "main": "path/to/main.css", "ignore": [ ".jshintrc", "**/*.txt" ], "dependencies": { "<name>": "<version>" }, "devDependencies": { "<test-framework-name>": "<version>" } }
Registering a package $ bower register <package-name> <git-endpoint> a valid
manifest JSON Git tags (using semver) be available at a Git endpoint (e.g., GitHub); remember to push your Git tags!
Bugsense.js plugin (see Gruntfile.js & bower.json) Addy Osmani presentation Grunt
plugins Bower homepage (incl. Yeomann) Grunt homepage
Thanks! twitter @tsironakos github @tsironis