Top Banner
GETTING STARTED WITH GRUNT FOR WORDPRESS DEVELOPMENT David “DANGER” Bisset WORDPRESS MEETUP - OCTOBER 2014
30

Getting Started With Grunt for WordPress Development

Jul 11, 2015

Download

Technology

dimensionmedia
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Getting Started With Grunt for WordPress Development

GETTING STARTED WITH GRUNT FOR WORDPRESS DEVELOPMENTDavid “DANGER” Bisset WORDPRESS MEETUP - OCTOBER 2014

Page 2: Getting Started With Grunt for WordPress Development

What Is A Task Runner?

A task runner (or build system) is a script that executes a list of actions,

typically using one or more plugins.

Page 3: Getting Started With Grunt for WordPress Development

PREPROCESSING

WHAT CAN YOU DO?

• SASS

• LESS

• COFFEESCRIPT

Page 4: Getting Started With Grunt for WordPress Development

MINIFY

WHAT CAN YOU DO?

• CSS

• JAVASCRIPT

Page 5: Getting Started With Grunt for WordPress Development

MINIFY

WHAT CAN YOU DO?

Page 6: Getting Started With Grunt for WordPress Development

WHAT CAN YOU DO?

• JSHINT

• JSLINT

LINT FILES

Page 7: Getting Started With Grunt for WordPress Development

REFRESH BROWSER EACH TIME YOU MAKE A CHANGE TO A FILE

WHAT CAN YOU DO?

LIVE RELOAD CHANGES

Page 8: Getting Started With Grunt for WordPress Development

• START A WEB SERVER

• OPTIMIZE IMAGES

• OUTPUT TO HTML

• ALMOST ANYTHING!

WHAT CAN YOU DO?

Other THINGS:

Page 9: Getting Started With Grunt for WordPress Development

Popular Task Runners

• GRUNT.JS

• GULP.JS

• CAKE

• BRUNCH

• BROCCOLI

Page 10: Getting Started With Grunt for WordPress Development

GRUNT.JS

LET’S TAKE A LOOK

Page 11: Getting Started With Grunt for WordPress Development

Why Go With Grunt.JS?

• Grunt.js is built on Node.js

• It’s the most popular task runner

• The community is large (and helpful)

• Thousands of available plugins

• Building custom plugins is really easy

Page 12: Getting Started With Grunt for WordPress Development

NODE.JS

GRUNT REQUIRES:

Page 13: Getting Started With Grunt for WordPress Development

What Is Node.JS?

NODE.JS IS JAVASCRIPT THAT RUNS ON A SERVER OR A TERMINAL

Page 14: Getting Started With Grunt for WordPress Development

How Do You Install Node.JS?

HTTP://NODEJS.ORG

Page 15: Getting Started With Grunt for WordPress Development

NPM (NODE PACKAGE MANAGER)

NODE.JS COMES WITH:

Page 16: Getting Started With Grunt for WordPress Development

npm install -g grunt-cli

Installing Grunt CLI (Command Line Interface)

http://gruntjs.com/getting-started

Page 17: Getting Started With Grunt for WordPress Development

package.json

PREPARING A NEW GRUNT PROJECT

Page 18: Getting Started With Grunt for WordPress Development

Gruntfile.js

PREPARING A NEW GRUNT PROJECT

Page 19: Getting Started With Grunt for WordPress Development

Uglify

Installing grunt modules

Page 20: Getting Started With Grunt for WordPress Development

npm install grunt-contrib-uglify --save-dev

Installing Uglify

https://github.com/gruntjs/grunt-contrib-uglify

Page 21: Getting Started With Grunt for WordPress Development

Go Back To Gruntfile.js

grunt

Page 22: Getting Started With Grunt for WordPress Development

Go Back To Gruntfile.js

grunt uglify

Page 23: Getting Started With Grunt for WordPress Development

Watch

Installing grunt modules

Page 24: Getting Started With Grunt for WordPress Development

npm install grunt-contrib-watch --save-dev

Installing Uglify

https://www.npmjs.org/package/grunt-contrib-watch

Page 25: Getting Started With Grunt for WordPress Development

Go Back To Gruntfile.js

Page 26: Getting Started With Grunt for WordPress Development

How File Matching Works// Matches a single file files: 'foo.js' !// Matches an array of files files: [ 'foo.js', 'bar.js' ] !// Matches all files in the dir files: '*' !// Matches all files with a given extension in the dir files: '*.js' !// Matches all files with a given extension in all dirs files: '**/*.js' !// Matches all files w/extension in this dir and one dir deeper files: '{,*/}*.js'

Page 27: Getting Started With Grunt for WordPress Development

Other Cool Links To Check Out

https://www.npmjs.org/package/grunt-wordpress-deploy

Deploy a Wordpress instance without pain using Grunt.

you can define different environments.

Adapt the Wordpress database to the destination domain.

Page 28: Getting Started With Grunt for WordPress Development

Other Cool Links To Check Out

https://github.com/10up/grunt-wp-plugin

Create a WordPress plugin with grunt-init.

Create a WordPress THEME with grunt-init.

https://github.com/10up/grunt-wp-theme

Page 29: Getting Started With Grunt for WordPress Development

Other Cool Links To Check Out

https://github.com/roots/roots

WordPress starter theme based on HTML5 Boilerplate & Bootstrap

MORE READING!

https://mondaybynoon.com/grunt-wordpress-theme-development/

Page 30: Getting Started With Grunt for WordPress Development

THANK YOU.David “SHOULD HAVE HAD A V8” Bisset davidbisset.com / @dimensionmedia