SlideShare a Scribd company logo
1 of 23
Download to read offline
Grunt:
the wild boar
dev’s best
friend
Hello!
Software Engineer
Lead Engineer @ Black Studio
Web Developer since 1998
WordPress Lover since 2010
I'm Marco Chiesi
@marcochiesi
www.blackstudio.it
DEVELOPERS
ARE LAZY!
I choose a lazy person
to do a hard job.
Because a lazy person
will find an easy way
to do it.
- Bill Gates
Founder of Microsoft
The three great virtues
of a programmer:
laziness, impatience,
and hubris.
- Larry Wall
Creator of PERL language
The solution for
laziness is...
AUTOMATION
What is GRUNT?
× Grunt is a task runner
× Written in JavaScript
× Node.js module
× Command line
× Configurable on a
per-project basis
https://gruntjs.com
Why use GRUNT?
× Automation of repetitive tasks with
minimum effort
× Open source
× Large community
× Hundreds of plugins available
× Easy to set up and use
× Build your own Grunt plugins
Typical Grunt uses
× CSS/JS minification and
concatenation
× SASS/LESS compilation
× Unit testing
× Code linting
× Code/Text processing
× Image optimization
× ....
Who uses Grunt?
WP Core ...and many others!
Grunt requirements
Software requirements:
× Node.js
× npm (node package manager)
"Human" requirements:
× Basic JavaScript knowledge
× Familiarity with the command line
Getting started
1. Download and install Node.js from
https://nodejs.org
2. Ensure npm is up to date:
npm update -g npm
3. Install Grunt CLI globally:
npm install -g grunt-cli
Grunt-related files and folders
package.json
⇒ File for module dependencies
Gruntfile.js
⇒ File for tasks definition
node_modules
⇒ Folder hosting node.js modules
Include in
versioning
Exclude from
versioning
Working with an existing Grunt project
1. Change to the project's root directory
cd <folder>
2. Install project dependencies:
npm install
3. Run Grunt:
grunt or grunt <task>
Preparing a new Grunt project
1. Create project folder: md <folder>
2. Initialize package.json: npm init
3. Create empty Gruntfile.js
4. Install Grunt and Grunt plugins:
npm install grunt --save-dev
npm install <plugin> --save-dev
5. Edit Gruntfile.js
6. Run Grunt: grunt or grunt <task>
Sample package.json
{
"name": "my-project-name",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-uglify": "~0.5.0"
}
}
Sample Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
...
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['uglify']);
};
Configure tasks
Load npm packages
Register tasks
CSS and JavaScript processinG
CSS
× Minification/combination: grunt-contrib-cssmin
× Linting: stylelint + grunt-stylelint
JavaScript
× Minification/combination: grunt-contrib-uglify
× Linting: grunt-contrib-jshint or
eslint + grunt-eslint
Watch
The grunt-contrib-watch plugin allows to run
predefined tasks whenever watched file patterns
are added, changed or deleted.
// Run jshint any time a file is added, changed or deleted
grunt.initConfig({
watch: {
files: ['**/*'],
tasks: ['jshint'],
},
});
Internationalization
grunt-wp-i18n
× Generate POT files from source code
× Add textdomain where it is missing
grunt-potomo
× Compile .po files into binary .mo files
WordPress coding standards
PHP
grunt-phpcs (+ PHP_CodeSniffer + WPCS rules)
CSS
stylelint-config-wordpress
(+ stylelint + grunt-stylelint)
JavaScript
eslint-config-wordpress (+ eslint + grunt-eslint)
Some other WP-specific Grunt plugins
grunt-wp-readme-to-markdown
× Convert plugin's readme.txt to Markdown
format (good for GitHub)
grunt-checkwpversion
× Check consistency of version number in
different points of the project
grunt-wp-deploy
× Deploy from Git to wordpress.org SVN repo
Thanks!
Credits:
Presentation template by SlidesCarnival
Pictures:
- "Wild Boar" by Dmitry Abramov (Pixabay)
- "Cat Sleeping" by wallpaperspoints (Chainimage)
- "Bill Gates" by DFID - UK (Wikipedia)
- "Larry Wall" by Randal Schwartz (Wikipedia)
Any questions?
@marcochiesi
marco@blackstudio.it
Slides available at:
blackstudio.it/en/talks/

More Related Content

What's hot

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
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsRémy Savard
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBHengki Sihombing
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)zerok
 
Diving into Node with Express and Mongo
Diving into Node with Express and MongoDiving into Node with Express and Mongo
Diving into Node with Express and MongoAxilis
 
Getting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentGetting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentDavid Bisset
 
Modern Development Tools
Modern Development ToolsModern Development Tools
Modern Development ToolsYe Maw
 
Introduction to zc.buildout
Introduction to zc.buildoutIntroduction to zc.buildout
Introduction to zc.buildoutRicardo Newbery
 
Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013Jon Peck
 
Herramientas front
Herramientas frontHerramientas front
Herramientas frontborya09
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflowRiccardo Coppola
 
Drush and drupal. администрирование волчек михаил
Drush and drupal. администрирование  волчек михаилDrush and drupal. администрирование  волчек михаил
Drush and drupal. администрирование волчек михаилdrupalconf
 
Ansible
AnsibleAnsible
Ansiblegnosek
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaSalvador Molina (Slv_)
 

What's hot (20)

Grunt All Day
Grunt All DayGrunt All Day
Grunt All Day
 
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
 
Deep dive-oz
Deep dive-ozDeep dive-oz
Deep dive-oz
 
GruntJS + Wordpress
GruntJS + WordpressGruntJS + Wordpress
GruntJS + Wordpress
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.js
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)
 
Diving into Node with Express and Mongo
Diving into Node with Express and MongoDiving into Node with Express and Mongo
Diving into Node with Express and Mongo
 
Getting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress DevelopmentGetting Started With Grunt for WordPress Development
Getting Started With Grunt for WordPress Development
 
Modern Development Tools
Modern Development ToolsModern Development Tools
Modern Development Tools
 
Introduction to zc.buildout
Introduction to zc.buildoutIntroduction to zc.buildout
Introduction to zc.buildout
 
Grunt and Bower
Grunt and BowerGrunt and Bower
Grunt and Bower
 
Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013
 
Herramientas front
Herramientas frontHerramientas front
Herramientas front
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
 
Drush and drupal. администрирование волчек михаил
Drush and drupal. администрирование  волчек михаилDrush and drupal. администрирование  волчек михаил
Drush and drupal. администрирование волчек михаил
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
 
Ansible
AnsibleAnsible
Ansible
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molina
 
Npm: beyond 'npm i'
Npm: beyond 'npm i'Npm: beyond 'npm i'
Npm: beyond 'npm i'
 

Similar to Grunt: the wild boar dev's best friend

Grunt understanding
Grunt understandingGrunt understanding
Grunt understandingKhalid Khan
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and DrushPantheon
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"? Fabien Doiron
 
Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsJosh Lee
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deckJames Ford
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentJames Bundey
 
Preprocessor Workflow with Grunt
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with GruntVlad Filippov
 
Bootstrapping your plugin
Bootstrapping your pluginBootstrapping your plugin
Bootstrapping your pluginMarko Heijnen
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsVisual Engineering
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Future Insights
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end WorkflowPagepro
 
Automating Front-End Workflow
Automating Front-End WorkflowAutomating Front-End Workflow
Automating Front-End WorkflowDimitris Tsironis
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsMichael Lange
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with pythonroskakori
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817Dan Dineen
 

Similar to Grunt: the wild boar dev's best friend (20)

Using GruntJS
Using GruntJSUsing GruntJS
Using GruntJS
 
Grunt
GruntGrunt
Grunt
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understanding
 
Grunt
GruntGrunt
Grunt
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.js
 
GruntJS
GruntJSGruntJS
GruntJS
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
 
Front end development gurant
Front end development gurantFront end development gurant
Front end development gurant
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme development
 
Preprocessor Workflow with Grunt
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with Grunt
 
Bootstrapping your plugin
Bootstrapping your pluginBootstrapping your plugin
Bootstrapping your plugin
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Automating Front-End Workflow
Automating Front-End WorkflowAutomating Front-End Workflow
Automating Front-End Workflow
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with python
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817
 

Recently uploaded

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Grunt: the wild boar dev's best friend

  • 2. Hello! Software Engineer Lead Engineer @ Black Studio Web Developer since 1998 WordPress Lover since 2010 I'm Marco Chiesi @marcochiesi www.blackstudio.it
  • 4. I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it. - Bill Gates Founder of Microsoft
  • 5. The three great virtues of a programmer: laziness, impatience, and hubris. - Larry Wall Creator of PERL language
  • 6. The solution for laziness is... AUTOMATION
  • 7. What is GRUNT? × Grunt is a task runner × Written in JavaScript × Node.js module × Command line × Configurable on a per-project basis https://gruntjs.com
  • 8. Why use GRUNT? × Automation of repetitive tasks with minimum effort × Open source × Large community × Hundreds of plugins available × Easy to set up and use × Build your own Grunt plugins
  • 9. Typical Grunt uses × CSS/JS minification and concatenation × SASS/LESS compilation × Unit testing × Code linting × Code/Text processing × Image optimization × ....
  • 10. Who uses Grunt? WP Core ...and many others!
  • 11. Grunt requirements Software requirements: × Node.js × npm (node package manager) "Human" requirements: × Basic JavaScript knowledge × Familiarity with the command line
  • 12. Getting started 1. Download and install Node.js from https://nodejs.org 2. Ensure npm is up to date: npm update -g npm 3. Install Grunt CLI globally: npm install -g grunt-cli
  • 13. Grunt-related files and folders package.json ⇒ File for module dependencies Gruntfile.js ⇒ File for tasks definition node_modules ⇒ Folder hosting node.js modules Include in versioning Exclude from versioning
  • 14. Working with an existing Grunt project 1. Change to the project's root directory cd <folder> 2. Install project dependencies: npm install 3. Run Grunt: grunt or grunt <task>
  • 15. Preparing a new Grunt project 1. Create project folder: md <folder> 2. Initialize package.json: npm init 3. Create empty Gruntfile.js 4. Install Grunt and Grunt plugins: npm install grunt --save-dev npm install <plugin> --save-dev 5. Edit Gruntfile.js 6. Run Grunt: grunt or grunt <task>
  • 16. Sample package.json { "name": "my-project-name", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.5", "grunt-contrib-jshint": "~0.10.0", "grunt-contrib-uglify": "~0.5.0" } }
  • 17. Sample Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { ... } }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['uglify']); }; Configure tasks Load npm packages Register tasks
  • 18. CSS and JavaScript processinG CSS × Minification/combination: grunt-contrib-cssmin × Linting: stylelint + grunt-stylelint JavaScript × Minification/combination: grunt-contrib-uglify × Linting: grunt-contrib-jshint or eslint + grunt-eslint
  • 19. Watch The grunt-contrib-watch plugin allows to run predefined tasks whenever watched file patterns are added, changed or deleted. // Run jshint any time a file is added, changed or deleted grunt.initConfig({ watch: { files: ['**/*'], tasks: ['jshint'], }, });
  • 20. Internationalization grunt-wp-i18n × Generate POT files from source code × Add textdomain where it is missing grunt-potomo × Compile .po files into binary .mo files
  • 21. WordPress coding standards PHP grunt-phpcs (+ PHP_CodeSniffer + WPCS rules) CSS stylelint-config-wordpress (+ stylelint + grunt-stylelint) JavaScript eslint-config-wordpress (+ eslint + grunt-eslint)
  • 22. Some other WP-specific Grunt plugins grunt-wp-readme-to-markdown × Convert plugin's readme.txt to Markdown format (good for GitHub) grunt-checkwpversion × Check consistency of version number in different points of the project grunt-wp-deploy × Deploy from Git to wordpress.org SVN repo
  • 23. Thanks! Credits: Presentation template by SlidesCarnival Pictures: - "Wild Boar" by Dmitry Abramov (Pixabay) - "Cat Sleeping" by wallpaperspoints (Chainimage) - "Bill Gates" by DFID - UK (Wikipedia) - "Larry Wall" by Randal Schwartz (Wikipedia) Any questions? @marcochiesi marco@blackstudio.it Slides available at: blackstudio.it/en/talks/