Bower & Grunt - A practical workflow

Riccardo Coppola
Riccardo CoppolaSenior UI developer at lastminute.com
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!
1 of 31

Recommended

Grunt and Bower by
Grunt and BowerGrunt and Bower
Grunt and BowerGeorge Estebe
1.2K views10 slides
Production Ready Javascript With Grunt by
Production Ready Javascript With GruntProduction Ready Javascript With Grunt
Production Ready Javascript With GruntXB Software, Ltd.
4.6K views54 slides
Introduction to Express and Grunt by
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and GruntPeter deHaan
10.7K views17 slides
Bower - A package manager for the web by
Bower - A package manager for the webBower - A package manager for the web
Bower - A package manager for the webLarry Nung
847 views76 slides
Preprocessor Workflow with Grunt by
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with GruntVlad Filippov
10.8K views39 slides
Grunt to automate JS build by
Grunt to automate JS buildGrunt to automate JS build
Grunt to automate JS buildTejaswita Takawale
5.1K views11 slides

More Related Content

What's hot

Grunt.js and Yeoman, Continous Integration by
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
30.8K views63 slides
Front-end development automation with Grunt by
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Gruntbenko
5.2K views36 slides
Bower power by
Bower powerBower power
Bower powerEric Carlisle
2.2K views28 slides
Yeoman by
YeomanYeoman
YeomanJames Cryer
6.2K views25 slides
Advanced front-end automation with npm scripts by
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsk88hudson
2.9K views53 slides
Npm scripts by
Npm scriptsNpm scripts
Npm scripts정윤 김
1.5K views71 slides

What's hot(20)

Grunt.js and Yeoman, Continous Integration by David Amend
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend30.8K views
Front-end development automation with Grunt by benko
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
benko5.2K views
Advanced front-end automation with npm scripts by k88hudson
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
k88hudson2.9K views
Npm scripts by 정윤 김
Npm scriptsNpm scripts
Npm scripts
정윤 김1.5K views
GDG Kraków - Intro to front-end automation using bower.js & grunt.js by Dominik Prokop
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
Dominik Prokop1.2K views
Continuous Integration for front-end JavaScript by Lars Thorup
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
Lars Thorup6.4K views
Let Grunt do the work, focus on the fun! [Open Web Camp 2013] by Dirk Ginader
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 Ginader20.7K views
How we maintain 200+ Drupal sites in Georgetown University by Ovadiah Myrgorod
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
Ovadiah Myrgorod2.5K views
What makes me "Grunt"? by Fabien Doiron
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
Fabien Doiron3.6K views
Grunt - The JavaScript Task Runner by Mohammed Arif
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
Mohammed Arif6.3K views
Packing for the Web with Webpack by Thiago Temple
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
Thiago Temple834 views

Viewers also liked

Ftr - Revisão técnica formal by
Ftr - Revisão técnica formalFtr - Revisão técnica formal
Ftr - Revisão técnica formalThalita Chaves
3.1K views1 slide
Unit testing of java script and angularjs application using Karma Jasmine Fra... by
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
1.1K views17 slides
Insights on Protractor testing by
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testingDejan Toteff
1.3K views24 slides
Publish Subscribe pattern - Design Patterns by
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsRutvik Bapat
10.7K views14 slides
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp by
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
52.6K views144 slides
Publish and Subscribe by
Publish and SubscribePublish and Subscribe
Publish and SubscribeAlexandru Badiu
3.6K views16 slides

Viewers also liked(20)

Ftr - Revisão técnica formal by Thalita Chaves
Ftr - Revisão técnica formalFtr - Revisão técnica formal
Ftr - Revisão técnica formal
Thalita Chaves3.1K views
Unit testing of java script and angularjs application using Karma Jasmine Fra... by Samyak Bhalerao
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 Bhalerao1.1K views
Insights on Protractor testing by Dejan Toteff
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testing
Dejan Toteff1.3K views
Publish Subscribe pattern - Design Patterns by Rutvik Bapat
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design Patterns
Rutvik Bapat10.7K views
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp by Matthew Davis
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
Matthew Davis52.6K views
Protractor framework – how to make stable e2e tests for Angular applications by Ludmila Nesvitiy
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
Ludmila Nesvitiy4.4K views
Introduction to Angular 2 by Trung Vo Tuan
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
Trung Vo Tuan1.6K views
Functional Reactive Programming with RxJS by stefanmayer13
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
stefanmayer1340.4K views
Tipos de Organigramas / ASIGNACION I / O y M IUTAJS by Gustavo Pinedo
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
Gustavo Pinedo355 views
Otp authentication scheme based on ECC by POOJA MEHTA
Otp authentication scheme based on ECCOtp authentication scheme based on ECC
Otp authentication scheme based on ECC
POOJA MEHTA553 views
G10 Science Q1 by Jm Olaybar
G10 Science Q1G10 Science Q1
G10 Science Q1
Jm Olaybar613 views
Nota%20exam%20hadith[1] by yatie1977
Nota%20exam%20hadith[1]Nota%20exam%20hadith[1]
Nota%20exam%20hadith[1]
yatie1977325 views
The Avalon Media System: Implementation and Community by Avalon Media System
The Avalon Media System: Implementation and CommunityThe Avalon Media System: Implementation and Community
The Avalon Media System: Implementation and Community
Hybrid air conditioner by Amr Badra
Hybrid air conditioner Hybrid air conditioner
Hybrid air conditioner
Amr Badra269 views

Similar to Bower & Grunt - A practical workflow

Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools by
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
54.9K views178 slides
Angular Part 3 (Basic knowledge) by
Angular Part 3 (Basic knowledge)Angular Part 3 (Basic knowledge)
Angular Part 3 (Basic knowledge)Rohit Singh
54 views6 slides
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript by
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
619 views74 slides
Bower introduction by
Bower introductionBower introduction
Bower introductionOleksii Prohonnyi
578 views25 slides
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript by
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
585 views75 slides
PHP on Heroku: Deploying and Scaling Apps in the Cloud by
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
1.9K views40 slides

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

Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools by Ryan Weaver
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
Ryan Weaver54.9K views
Angular Part 3 (Basic knowledge) by Rohit Singh
Angular Part 3 (Basic knowledge)Angular Part 3 (Basic knowledge)
Angular Part 3 (Basic knowledge)
Rohit Singh54 views
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript by Horacio Gonzalez
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
Horacio Gonzalez619 views
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript by Horacio Gonzalez
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
Horacio Gonzalez585 views
PHP on Heroku: Deploying and Scaling Apps in the Cloud by Salesforce Developers
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
Distributing UI Libraries: in a post Web-Component world by Rachael L Moore
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
Rachael L Moore553 views
Docker module 1 by Liang Bo
Docker module 1Docker module 1
Docker module 1
Liang Bo603 views
Web development - technologies and tools by Yoann Gotthilf
Web development - technologies and toolsWeb development - technologies and tools
Web development - technologies and tools
Yoann Gotthilf1.1K views
Extending Build to the Client: A Maven User's Guide to Grunt.js by Petr Jiricka
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
Petr Jiricka2K views
Django dev-env-my-way by Robert Lujo
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
Robert Lujo941 views
The Modern Developer Toolbox by Pablo Godel
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
Pablo Godel2.6K views
Improving build solutions dependency management with webpack by NodeXperts
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
NodeXperts248 views
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond by DrupalDay
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
DrupalDay924 views
Once upon a time, there were css, js and server-side rendering by Andrea Giannantonio
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 by Giacomo Bagnoli
Streamline your development environment with dockerStreamline your development environment with docker
Streamline your development environment with docker
Giacomo Bagnoli1.8K views

Recently uploaded

MariaDB stored procedures and why they should be improved by
MariaDB stored procedures and why they should be improvedMariaDB stored procedures and why they should be improved
MariaDB stored procedures and why they should be improvedFederico Razzoli
8 views32 slides
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon by
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - AfternoonDSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - AfternoonDeltares
11 views43 slides
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...Deltares
10 views23 slides
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida by
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDeltares
17 views9 slides
SAP FOR CONTRACT MANUFACTURING.pdf by
SAP FOR CONTRACT MANUFACTURING.pdfSAP FOR CONTRACT MANUFACTURING.pdf
SAP FOR CONTRACT MANUFACTURING.pdfVirendra Rai, PMP
11 views2 slides
DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM... by
DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM...DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM...
DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM...Deltares
7 views40 slides

Recently uploaded(20)

MariaDB stored procedures and why they should be improved by Federico Razzoli
MariaDB stored procedures and why they should be improvedMariaDB stored procedures and why they should be improved
MariaDB stored procedures and why they should be improved
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon by Deltares
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - AfternoonDSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
Deltares11 views
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by Deltares
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
Deltares10 views
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida by Deltares
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
Deltares17 views
DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM... by Deltares
DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM...DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM...
DSD-INT 2023 Next-Generation Flood Inundation Mapping for Taiwan - Delft3D FM...
Deltares7 views
Les nouveautés produit Neo4j by Neo4j
 Les nouveautés produit Neo4j Les nouveautés produit Neo4j
Les nouveautés produit Neo4j
Neo4j27 views
Citi TechTalk Session 2: Kafka Deep Dive by confluent
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
confluent17 views
SUGCON ANZ Presentation V2.1 Final.pptx by Jack Spektor
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptx
Jack Spektor21 views
What Can Employee Monitoring Software Do?​ by wAnywhere
What Can Employee Monitoring Software Do?​What Can Employee Monitoring Software Do?​
What Can Employee Monitoring Software Do?​
wAnywhere18 views
Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ... by marksimpsongw
Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ...Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ...
Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ...
marksimpsongw74 views
A first look at MariaDB 11.x features and ideas on how to use them by Federico Razzoli
A first look at MariaDB 11.x features and ideas on how to use themA first look at MariaDB 11.x features and ideas on how to use them
A first look at MariaDB 11.x features and ideas on how to use them
Federico Razzoli44 views
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan... by Deltares
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...
Deltares10 views
Advanced API Mocking Techniques by Dimpy Adhikary
Advanced API Mocking TechniquesAdvanced API Mocking Techniques
Advanced API Mocking Techniques
Dimpy Adhikary18 views
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t... by Deltares
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
DSD-INT 2023 Thermobaricity in 3D DCSM-FM - taking pressure into account in t...
Deltares9 views
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ... by Deltares
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
Deltares9 views
Upgrading Incident Management with Icinga - Icinga Camp Milan 2023 by Icinga
Upgrading Incident Management with Icinga - Icinga Camp Milan 2023Upgrading Incident Management with Icinga - Icinga Camp Milan 2023
Upgrading Incident Management with Icinga - Icinga Camp Milan 2023
Icinga36 views
DSD-INT 2023 HydroMT model building and river-coast coupling in Python - Bove... by Deltares
DSD-INT 2023 HydroMT model building and river-coast coupling in Python - Bove...DSD-INT 2023 HydroMT model building and river-coast coupling in Python - Bove...
DSD-INT 2023 HydroMT model building and river-coast coupling in Python - Bove...
Deltares15 views

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" }, ... }