SlideShare a Scribd company logo
1 of 31
Download to read offline
Bower & Grunt 
A practical workflow 
riccardo coppola about.me/riccardocoppola
Workflow step 1: 
Bower 
Manage front end dependencies
What?
Web sites are made of lots of things — 
frameworks, libraries, assets, utilities, and 
rainbows. Bower manages all these things for 
you.
Why?
Declutter your lib/vendor folder 
Too often we end up with 5 different versions of 
the same library (jQuery is an always-working 
example...). 
Which one are we actually using?
Dependency management 
No more downloads from ten different 
websites to get your dependencies. 
No more version mismatch problems.
Automate dependency management 
$ bower install 
That’s it
vs 
● Flexible: install from Bower 
registry, GitHub, zip, fs location 
● created solely for the front-end 
and optimized with that in mind 
● flat dependency tree (just one 
lib for each type), good for 
front-end related stuff 
● Most commonly used for 
managing Node.js modules 
● works for the front-end too when 
combined with Browserify 
● nested dependency tree (size 
heavy), good for server side 
modules
How?
Install Bower 
$ npm install -g bower 
Bower requires Node, npm and Git.
Search for a package 
http://bower.io/docs/api/#search 
bower search <package>
Install a package 
# registered package (specific version) 
$ bower install jquery#1.2.3 
# GitHub shorthand 
$ bower install desandro/masonry 
http://bower.io/docs/api/#install 
# Git endpoint 
$ bower install git://github.com/user/package.git 
# URL 
$ bower install http://example.com/script.jsv
Maintaining dependencies 
# install package and add it to bower.json 
dependencies 
$ bower install <package> --save 
# install package and add it to bower.json 
devDependencies 
$ bower install <package> --save-dev
bower.json (bower.json : bower = package.json : npm) 
{ 
"name": "my-project", 
"version": "1.0.0", 
"main": "path/to/main.css", 
"ignore": [ 
".jshintrc", 
"**/*.txt" 
], 
"dependencies": { 
"<name>": "<version>", 
"<name>": "<folder>", 
"<name>": "<package>" 
}, 
"devDependencies": { 
"<test-framework-name>": "<version>" 
} 
}
Is it enough? 
Bower is just a tool, helps us organize front 
end dependencies and keeps track of versions.
What we get 
➔ CSS and JS in the same folder 
➔ docs/ tests/ src/ minified versions and sourcemaps 
are all not needed 
➔ Bower components folder can grow if not cleaned
What we want 
➔ separated vendor folders for CSS and JS 
➔ single, non minified version of every lib, nothing else 
➔ clean vendor folder containing just used libs and only 
one version
Workflow step 2: 
grunt-bowercopy 
Scrupulously manage file locations for 
bower dependencies.
Why 
➔ Consistently positions your dependencies where you 
want them in your repository. 
➔ Conveniently facilitates tracking your dependencies 
without committing the entire Bower components folder. 
➔ Has the potential to reduce build times dramatically. 
➔ By default, runs bower install for you
https://www.npmjs.org/package/grunt-bowercopy 
$ npm install grunt-bowercopy --save-dev
grunt/bowercopy.js 
js: { 
options: { 
destPrefix: 'public/js/vendor 
}, 
files: { 
'jquery.js': 'jquery/jquery.js', 
'require.js': 'requirejs/require.js' 
}, 
}, 
sass: { 
options: { 
destPrefix: 'public/css/vendor 
}, 
files: { 
'bootstrap': 'bootstrap-sass-official/bootstrap.js' 
}, 
}, 
...
Workflow step 3: 
grunt-contrib-clean 
Clear files and folders
https://www.npmjs.org/package/grunt-contrib-clean 
$ npm install grunt-contrib-clean --save-dev
grunt/clean.js 
{ 
vendor: ["public/css/vendor/*", "public/js/vendor/*"] 
}
Everything together
aliases.js 
{ 
vendor: ["clean:vendor", "bowercopy:js", "bowercopy:sass"] 
}
If you commit your dependencies 
1. .gitignore the Bower component folder 
2. Add a hook on git pre-commit and run ‘grunt 
vendor’ as part of your pre-commit workflow 
3. Push your public/css/vendor & public/js/vendor
If you DO NOT commit your 
dependencies 
1. .gitignore the Bower component folder, 
public/css/vendor & public/js/vendor 
2. Have your CI run ‘npm install’ as first step of the front 
end workflow 
3. Modify your package.json
package.json 
{ 
"name": "myApp", 
"version": "0.1.0", 
... 
"scripts": { 
"postinstall": "./node_modules/grunt/bin/grunt vendor" 
}, 
... 
}
That’s all folks!

More Related Content

What's hot

Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Gruntbenko
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsk88hudson
 
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.jsGDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.jsDominik Prokop
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundlerAndrea Giannantonio
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptLars Thorup
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Dirk Ginader
 
How we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityHow we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityOvadiah Myrgorod
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"? Fabien Doiron
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerMohammed Arif
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with WebpackThiago Temple
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodologyAleksander Fabijan
 

What's hot (20)

Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
 
Bower power
Bower powerBower power
Bower power
 
Yeoman
YeomanYeoman
Yeoman
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
 
Npm scripts
Npm scriptsNpm scripts
Npm scripts
 
Webpack: from 0 to 2
Webpack: from 0 to 2Webpack: from 0 to 2
Webpack: from 0 to 2
 
Webpack DevTalk
Webpack DevTalkWebpack DevTalk
Webpack DevTalk
 
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.jsGDG Kraków - Intro to front-end automation using bower.js & grunt.js
GDG Kraków - Intro to front-end automation using bower.js & grunt.js
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundler
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 
How we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityHow we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown University
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
 
Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
Hey webpack
Hey webpackHey webpack
Hey webpack
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodology
 

Viewers also liked

Ftr - Revisão técnica formal
Ftr - Revisão técnica formalFtr - Revisão técnica formal
Ftr - Revisão técnica formalThalita Chaves
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Samyak Bhalerao
 
Insights on Protractor testing
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testingDejan Toteff
 
Publish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsRutvik Bapat
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpMatthew Davis
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overviewIshraq Al Fataftah
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Trung Vo Tuan
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 
Tipos de Organigramas / ASIGNACION I / O y M IUTAJS
Tipos de Organigramas / ASIGNACION I / O y M IUTAJSTipos de Organigramas / ASIGNACION I / O y M IUTAJS
Tipos de Organigramas / ASIGNACION I / O y M IUTAJSGustavo Pinedo
 
Otp authentication scheme based on ECC
Otp authentication scheme based on ECCOtp authentication scheme based on ECC
Otp authentication scheme based on ECCPOOJA MEHTA
 
G10 Science Q1
G10 Science Q1G10 Science Q1
G10 Science Q1Jm Olaybar
 
Nota%20exam%20hadith[1]
Nota%20exam%20hadith[1]Nota%20exam%20hadith[1]
Nota%20exam%20hadith[1]yatie1977
 
The Avalon Media System: Implementation and Community
The Avalon Media System: Implementation and CommunityThe Avalon Media System: Implementation and Community
The Avalon Media System: Implementation and CommunityAvalon Media System
 
Hybrid air conditioner
Hybrid air conditioner Hybrid air conditioner
Hybrid air conditioner Amr Badra
 

Viewers also liked (20)

Ftr - Revisão técnica formal
Ftr - Revisão técnica formalFtr - Revisão técnica formal
Ftr - Revisão técnica formal
 
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing of java script and angularjs application using Karma Jasmine Fra...
 
Insights on Protractor testing
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testing
 
Publish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design Patterns
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
Publish and Subscribe
Publish and SubscribePublish and Subscribe
Publish and Subscribe
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overview
 
Workshop - E2e tests with protractor
Workshop - E2e tests with protractorWorkshop - E2e tests with protractor
Workshop - E2e tests with protractor
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Tipos de Organigramas / ASIGNACION I / O y M IUTAJS
Tipos de Organigramas / ASIGNACION I / O y M IUTAJSTipos de Organigramas / ASIGNACION I / O y M IUTAJS
Tipos de Organigramas / ASIGNACION I / O y M IUTAJS
 
Pequeña empresa luciana muro
Pequeña empresa luciana muroPequeña empresa luciana muro
Pequeña empresa luciana muro
 
Otp authentication scheme based on ECC
Otp authentication scheme based on ECCOtp authentication scheme based on ECC
Otp authentication scheme based on ECC
 
Eord rotines
Eord rotinesEord rotines
Eord rotines
 
G10 Science Q1
G10 Science Q1G10 Science Q1
G10 Science Q1
 
Nota%20exam%20hadith[1]
Nota%20exam%20hadith[1]Nota%20exam%20hadith[1]
Nota%20exam%20hadith[1]
 
Ekonomi
EkonomiEkonomi
Ekonomi
 
The Avalon Media System: Implementation and Community
The Avalon Media System: Implementation and CommunityThe Avalon Media System: Implementation and Community
The Avalon Media System: Implementation and Community
 
Hybrid air conditioner
Hybrid air conditioner Hybrid air conditioner
Hybrid air conditioner
 

Similar to Bower & Grunt - A practical workflow

Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsRyan Weaver
 
Angular Part 3 (Basic knowledge)
Angular Part 3 (Basic knowledge)Angular Part 3 (Basic knowledge)
Angular Part 3 (Basic knowledge)Rohit Singh
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptHoracio Gonzalez
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudSalesforce Developers
 
Distributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component worldDistributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component worldRachael L Moore
 
Docker module 1
Docker module 1Docker module 1
Docker module 1Liang Bo
 
Web development - technologies and tools
Web development - technologies and toolsWeb development - technologies and tools
Web development - technologies and toolsYoann Gotthilf
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsPetr Jiricka
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer ToolboxPablo Godel
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpackNodeXperts
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupalDay
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingAndrea Giannantonio
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with dockerGiacomo Bagnoli
 

Similar to Bower & Grunt - A practical workflow (20)

Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
 
Angular Part 3 (Basic knowledge)
Angular Part 3 (Basic knowledge)Angular Part 3 (Basic knowledge)
Angular Part 3 (Basic knowledge)
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
 
Bower introduction
Bower introductionBower introduction
Bower introduction
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
Front-end tools
Front-end toolsFront-end tools
Front-end tools
 
Distributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component worldDistributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component world
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Web development - technologies and tools
Web development - technologies and toolsWeb development - technologies and tools
Web development - technologies and tools
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
 
Docker in production
Docker in productionDocker in production
Docker in production
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
 
Composer
ComposerComposer
Composer
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
 
Maven
MavenMaven
Maven
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
Streamline your development environment with docker
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
 

Recently uploaded

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 

Recently uploaded (20)

2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 

Bower & Grunt - A practical workflow

  • 1. Bower & Grunt A practical workflow riccardo coppola about.me/riccardocoppola
  • 2. Workflow step 1: Bower Manage front end dependencies
  • 4. Web sites are made of lots of things — frameworks, libraries, assets, utilities, and rainbows. Bower manages all these things for you.
  • 6. Declutter your lib/vendor folder Too often we end up with 5 different versions of the same library (jQuery is an always-working example...). Which one are we actually using?
  • 7. Dependency management No more downloads from ten different websites to get your dependencies. No more version mismatch problems.
  • 8. Automate dependency management $ bower install That’s it
  • 9. vs ● Flexible: install from Bower registry, GitHub, zip, fs location ● created solely for the front-end and optimized with that in mind ● flat dependency tree (just one lib for each type), good for front-end related stuff ● Most commonly used for managing Node.js modules ● works for the front-end too when combined with Browserify ● nested dependency tree (size heavy), good for server side modules
  • 10. How?
  • 11. Install Bower $ npm install -g bower Bower requires Node, npm and Git.
  • 12. Search for a package http://bower.io/docs/api/#search bower search <package>
  • 13. Install a package # registered package (specific version) $ bower install jquery#1.2.3 # GitHub shorthand $ bower install desandro/masonry http://bower.io/docs/api/#install # Git endpoint $ bower install git://github.com/user/package.git # URL $ bower install http://example.com/script.jsv
  • 14. Maintaining dependencies # install package and add it to bower.json dependencies $ bower install <package> --save # install package and add it to bower.json devDependencies $ bower install <package> --save-dev
  • 15. bower.json (bower.json : bower = package.json : npm) { "name": "my-project", "version": "1.0.0", "main": "path/to/main.css", "ignore": [ ".jshintrc", "**/*.txt" ], "dependencies": { "<name>": "<version>", "<name>": "<folder>", "<name>": "<package>" }, "devDependencies": { "<test-framework-name>": "<version>" } }
  • 16. Is it enough? Bower is just a tool, helps us organize front end dependencies and keeps track of versions.
  • 17. What we get ➔ CSS and JS in the same folder ➔ docs/ tests/ src/ minified versions and sourcemaps are all not needed ➔ Bower components folder can grow if not cleaned
  • 18. What we want ➔ separated vendor folders for CSS and JS ➔ single, non minified version of every lib, nothing else ➔ clean vendor folder containing just used libs and only one version
  • 19. Workflow step 2: grunt-bowercopy Scrupulously manage file locations for bower dependencies.
  • 20. Why ➔ Consistently positions your dependencies where you want them in your repository. ➔ Conveniently facilitates tracking your dependencies without committing the entire Bower components folder. ➔ Has the potential to reduce build times dramatically. ➔ By default, runs bower install for you
  • 21. https://www.npmjs.org/package/grunt-bowercopy $ npm install grunt-bowercopy --save-dev
  • 22. grunt/bowercopy.js js: { options: { destPrefix: 'public/js/vendor }, files: { 'jquery.js': 'jquery/jquery.js', 'require.js': 'requirejs/require.js' }, }, sass: { options: { destPrefix: 'public/css/vendor }, files: { 'bootstrap': 'bootstrap-sass-official/bootstrap.js' }, }, ...
  • 23. Workflow step 3: grunt-contrib-clean Clear files and folders
  • 24. https://www.npmjs.org/package/grunt-contrib-clean $ npm install grunt-contrib-clean --save-dev
  • 25. grunt/clean.js { vendor: ["public/css/vendor/*", "public/js/vendor/*"] }
  • 27. aliases.js { vendor: ["clean:vendor", "bowercopy:js", "bowercopy:sass"] }
  • 28. If you commit your dependencies 1. .gitignore the Bower component folder 2. Add a hook on git pre-commit and run ‘grunt vendor’ as part of your pre-commit workflow 3. Push your public/css/vendor & public/js/vendor
  • 29. If you DO NOT commit your dependencies 1. .gitignore the Bower component folder, public/css/vendor & public/js/vendor 2. Have your CI run ‘npm install’ as first step of the front end workflow 3. Modify your package.json
  • 30. package.json { "name": "myApp", "version": "0.1.0", ... "scripts": { "postinstall": "./node_modules/grunt/bin/grunt vendor" }, ... }