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
Esse cara é o Grunt
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Davidson Fellipe
December 15, 2013
Programming
900
9
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Esse cara é o Grunt
Davidson Fellipe
December 15, 2013
Transcript
60 slides
grunt esse cara é o @almirfilho @davidsonfellipe
None
@almirfilho @davidsonfellipe
globo .com
do workflow rei o front-end
linha de comando nodejs automatizador de tarefas
o grunt não é o único
ant java make shell cake coffeescript rake ruby
downloads 2013
100k 200k 300k downloads 2013 nov out set ago jul
jun mai abr mar fev jan
None
automatizamos? por que
repetitivo minimizar trabalho
detalhes muitos para lembrar
conversão frameworks e libs compilação linting testes minificação
complexos útil para projetos
rodar testes pré-processadores:dev js/css lint web server scaffolding otimizar imagens
criar sprites live reloading minificação e obfuscação concatenação pré-processadores:prod gerar release deploy dev prod
eficiência! produtividade!
paz de espírito
grunt iniciando com
node.js & npm primeiro as coisas primeiras
grunt-cli instalação global instalação local configuração configuração grunt & tools
package.json Gruntfile.js
$ npm install -g grunt-cli grunt-cli instalação global
{ "name": "dave-fulero", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-uglify":
"~0.2.2" } } package.json configuração
$ npm install grunt & tools instalação local
--save-dev $ npm install nome-pacote --save-dev
module.exports = function(grunt){ grunt.initConfig({ pkg: grunt.file.readJSON(‘package.json’), uglify: {/* configuração da
tarefa */} }); grunt.loadNpmTasks(‘grunt-contrib-uglify’); grunt.registerTask(‘default’, [‘uglify’]); } Gruntfile.js configuração
grunt.initConfig({ uglify: { options: { banner: ‘/* dave fulêro */\n’
}, build: { src: ‘src/<%= pkg.name %>.js’, dest: ‘build/<%= pkg.name %>.min.js’ } } });
pop quem é
concatenação de arquivos a.js e.js i.js o.js u.js vogais.js
$ npm install grunt-contrib-concat --save-dev grunt-contrib-concat o cara que concatena
seus arquivos
grunt.initConfig({ concat: { options: { separator: ';', }, dist: {
src: ['src/a.js', 'src/e.js'], dest: 'build/vogais.js', } } }); concat no Gruntfile.js
$ grunt concat concatenação rodando manualmente
obfuscação e minificação de scripts all.min.js all.js
var toSeconds = function(hour) { return hour * 3600; };
var toSeconds = function(a) { return a * 3600; }; var toSeconds=function(a){return a*3600;}; obfuscação minificação
$ npm install grunt-contrib-uglify --save-dev grunt-contrib-uglify o cara que comprime
seus arquivos
grunt.initConfig({ uglify: { build: { src: 'src/all.js', dest: 'build/all.min.js' }
} }); uglify no Gruntfile.js
$ grunt uglify obfuscação e minificação rodando manualmente
pré-processadores de código widget.scss widget.css
$ npm install grunt-contrib-compass --save-dev grunt-contrib-compass o cara que compila
seu sass
grunt.initConfig({ compass: { dev: { options: { sassDir: 'src/scss', cssDir:
'build/css', imagesDir: 'src/img', generatedImagesDir: 'build/img' } }, prod: { /* ... */ } }}); compass no Gruntfile.js
grunt.initConfig({ compass: { dev: { /* ... */ }, prod:
{ options: { sassDir: 'src/scss', cssDir: 'build/css', imagesDir: 'src/img', generatedImagesDir: 'build/img', outputStyle: 'compressed', noLineComments: true }}}}); compass no Gruntfile.js
$ grunt compass:dev compilação de sass $ grunt compass:prod rodando
manualmente
pré-processadores grunt-contrib-sass sass stylus less coffeescript grunt-contrib-stylus grunt-contrib-less grunt-contrib-coffee
testes automatizados specs sucesso erro
$ npm install grunt-contrib-jasmine --save-dev grunt-contrib-jasmine o cara que testa
seu código e te avisa
grunt.initConfig({ jasmine: { src: 'src/**/*.js', options: { specs: 'spec/*Spec.js', helpers:
'spec/*Helper.js' } } }); jasmine no Gruntfile.js
$ grunt jasmine rodando manualmente testes automatizados
suites de testes grunt-contrib-jasmine jasmine mocha qunit grunt-simple-mocha grunt-contrib-qunit
watch fique de olho widget.scss widget.css save file all.min.js all.js
$ npm install grunt-contrib-watch --save-dev grunt-contrib-watch o cara que vigia
tudo para você
grunt.initConfig({ watch: { build: { files: ['src/**/*.{scss, js}'], tasks: [
'compass:dev', 'concat', 'uglify' ] } } }); watch no Gruntfile.js
testes pré-processadores js/css lint criar sprites live reloading concatenação tarefas
comuns para watch
na prática globo esporte setup
6 semanas!
faça suas escolhas sabiamente
globo .com /talentos github.com/globocom/ IWantToWorkAtGloboCom
obrigado!
obrigado! /almirfilho /almirfilho /davidsonfellipe /davidsonfellipe
obrigado!
More Decks by Davidson Fellipe
See All by Davidson Fellipe
Adventures from Enzyme to React Testing Library
fellipe
1
420
O melhor da monitoração de web performance
fellipe
0
490
Guia do Front-end das galáxias
fellipe
3
300
Workflow para desenvolvimento web e mobile usando gruntjs
fellipe
2
170
Como é trabalhar na Globo.com?
fellipe
3
140
Guia prático de desenvolvimento front-end para django devs
fellipe
1
200
Practical guide for front-end development for Django Devs
fellipe
0
150
It's Javascript Time
fellipe
6
570
Frontend Engineers: Passado, presente e futuro
fellipe
2
570
Other Decks in Programming
See All in Programming
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
5.9k
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
350
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
240
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
120
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
330
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
360
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
270
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
260
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
6k
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
240
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
640
Joys of Absence: A Defence of Solitary Play
codingconduct
1
580
Producing Creativity
orderedlist
PRO
348
41k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
GraphQLとの向き合い方2022年版
quramy
50
15k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
Building an army of robots
kneath
307
47k
How to make the Groovebox
asonas
2
2.6k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Git: the NoSQL Database
bkeepers
PRO
433
67k
The SEO Collaboration Effect
kristinabergwall1
1
620
Abbi's Birthday
coloredviolet
5
11k