SlideShare ist ein Scribd-Unternehmen logo
1 von 20
/Fabien Doiron @fabien_doiron
WHAT'S INSIDE?
what is grunt
why use grunt
setup grunt dependencies
important commands
starting a new grunt project
grunt in action
FABIEN DOIRON?
Software Developer - Front End
 fabien-d fabien_doiron
WHAT IS GRUNT?
"cowboy" Ben Alman
(in other words: JavaScript task runner)
current stable version: 0.4.1
“task-based command line build tool for
JavaScript projects that makes performing
repetitive but necessary tasks trivial”
WHY USE GRUNT?
open source software
large community
ease of use
project sponsored by Bocoup
hundreds of plugins
or build your own
SETUP GRUNT DEPENDENCIES
INSTALL NODE + NPM
(I'd suggest looking at NVM)
www.nodejs.org
UNINSTALL GRUNT
if you've installed grunt globally in the past
npm uninstall -g grunt
INSTALL GRUNT CLI
(Command Line Interface)
does NOT install the grunt task runner
allows multiple version of grunt simultaneously
npm install -g grunt-cli
IMPORTANT GRUNT COMMANDS
installs all dev dependencies from package.json
'--save-dev' adds module to package.json as dev dependency
grunt modules are installed in 'node_modules/' directory
npm install
npm install {{PACKAGE_NAME}} --save-dev
grunt grunt {{TASK}}
grunt {{TASK}}:{{TARGET}}
STARTING A NEW GRUNT PROJECT
create 2 files
package.json Gruntfile.js
PACKAGE.JSON EXAMPLE
{
"name": "my-project",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.4.3"
}
}
GRUNTFILE.JS
easy as 1, 2, 3 ... 4*
1. install module
(terminal, project root directory)
2. load module
(Gruntfile.js)
npm install grunt-contrib-jshint --save-dev
grunt.loadNpmTasks('grunt-contrib-jshint');
3. configure task
(Gruntfile.js)
4. register task*
(Gruntfile.js) * register is optional
grunt.initConfig({
jshint: { ... }
});
grunt.registerTask('default', ['jshint']);
GRUNTFILE.JS EXAMPLE
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: { ... }
});
// Load the "jshint" task.
grunt.loadNpmTasks('grunt-contrib-jshint');
// Register task(s).
grunt.registerTask('default', ['jshint']);
};
GRUNT FOLDER STRUCTURE
node_modules/
grunt/
grunt-contrib-jshint/
Gruntfile.js
package.json
GRUNT IN ACTION
JS linting*
watch task*
JS minification
clean
JS testing (mocha/chai)
SASS -> CSS
dev tasks & prod tasks
replace scripts in HTML files
* build together
RESOURCES


nodejs.org
npmjs.org
gruntjs.com
gruntjs plugins
gruntjs stackoverflow
gruntjs
fabien-d
END

Weitere ähnliche Inhalte

Was ist angesagt?

DevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentDevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day Development
Rob Reynolds
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
twuniversity
 
A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
abodeltae
 

Was ist angesagt? (20)

Golang Microservices meetup
Golang Microservices meetupGolang Microservices meetup
Golang Microservices meetup
 
Annotation processing
Annotation processingAnnotation processing
Annotation processing
 
Seamless Continuous Deployment Using Docker Containers
Seamless Continuous Deployment Using Docker ContainersSeamless Continuous Deployment Using Docker Containers
Seamless Continuous Deployment Using Docker Containers
 
Frontend asset management with Bower and Gulp.js
Frontend asset management with Bower and Gulp.jsFrontend asset management with Bower and Gulp.js
Frontend asset management with Bower and Gulp.js
 
DevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day DevelopmentDevOps: Using Vagrant to Enhance Your Day to Day Development
DevOps: Using Vagrant to Enhance Your Day to Day Development
 
OpenShift for developers in action! - jbcnconf19
OpenShift for developers in action! - jbcnconf19OpenShift for developers in action! - jbcnconf19
OpenShift for developers in action! - jbcnconf19
 
Ubuntu Opportunistic Programming (Europython 2011)
Ubuntu Opportunistic Programming (Europython 2011)Ubuntu Opportunistic Programming (Europython 2011)
Ubuntu Opportunistic Programming (Europython 2011)
 
How do I install virtual box?
How do I install virtual box?How do I install virtual box?
How do I install virtual box?
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching model
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
GitFlow Workshop
GitFlow WorkshopGitFlow Workshop
GitFlow Workshop
 
A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
 
DevOps and Drupal
DevOps and DrupalDevOps and Drupal
DevOps and Drupal
 
Git flow workflow example
Git flow workflow exampleGit flow workflow example
Git flow workflow example
 
The State of Puppet - Dan Bode
The State of Puppet - Dan BodeThe State of Puppet - Dan Bode
The State of Puppet - Dan Bode
 
NLUUG Spring 2012 - OpenShift Primer
NLUUG Spring 2012 - OpenShift PrimerNLUUG Spring 2012 - OpenShift Primer
NLUUG Spring 2012 - OpenShift Primer
 
Odo improving the developer experience on OpenShift - hack & sangria
Odo   improving the developer experience on OpenShift - hack & sangriaOdo   improving the developer experience on OpenShift - hack & sangria
Odo improving the developer experience on OpenShift - hack & sangria
 
Embracing the Change: How to Win with Gutenberg
Embracing the Change: How to Win with GutenbergEmbracing the Change: How to Win with Gutenberg
Embracing the Change: How to Win with Gutenberg
 
Git workflows
Git workflowsGit workflows
Git workflows
 
A-Team-Vipul
A-Team-VipulA-Team-Vipul
A-Team-Vipul
 

Ähnlich wie Grunt Talk Given at Ottawa JS

Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
Docker, Inc.
 
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Philipp Burgmer
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Simon Boulet
 

Ähnlich wie Grunt Talk Given at Ottawa JS (20)

Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
 
Drone CI
Drone CIDrone CI
Drone CI
 
Lando - AddWeb Solution
Lando - AddWeb Solution Lando - AddWeb Solution
Lando - AddWeb Solution
 
Composer
ComposerComposer
Composer
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Frontend Build Tools - CC FE & UX
Frontend Build Tools - CC FE & UXFrontend Build Tools - CC FE & UX
Frontend Build Tools - CC FE & UX
 
Front end workflow with yeoman
Front end workflow with yeomanFront end workflow with yeoman
Front end workflow with yeoman
 
Prizm Installation Guide
Prizm Installation GuidePrizm Installation Guide
Prizm Installation Guide
 
Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talk
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 
Flatpak
FlatpakFlatpak
Flatpak
 
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
2014-08-19 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Chicago
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
 
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-App...
 
Grunt
GruntGrunt
Grunt
 
Multi-stage Docker builds to make building easy!
Multi-stage Docker builds to make building easy!Multi-stage Docker builds to make building easy!
Multi-stage Docker builds to make building easy!
 
Install MariaDB on IBM i - Tips, troubleshooting, and more
Install MariaDB on IBM i - Tips, troubleshooting, and moreInstall MariaDB on IBM i - Tips, troubleshooting, and more
Install MariaDB on IBM i - Tips, troubleshooting, and more
 
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
Deploying with Super Cow Powers (Hosting your own APT repository with reprepro)
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Grunt Talk Given at Ottawa JS