automate your wordpress workflow with grunt.js

26
Grunting WordPress Automate your WordPress development workflow with Grunt.js

Upload: josh-lee

Post on 24-Dec-2014

133 views

Category:

Internet


0 download

DESCRIPTION

A 20-minute introduction on using grunt.js to optimize your WordPress development workflow

TRANSCRIPT

Page 1: Automate your WordPress Workflow with Grunt.js

Grunting WordPressAutomate your WordPress development

workflow with Grunt.js

Page 2: Automate your WordPress Workflow with Grunt.js

Josh LeeOwner & Lead Developer / QC Creative

@joshleecreates

Page 3: Automate your WordPress Workflow with Grunt.js

Why Grunt?What can it do for me?

Page 4: Automate your WordPress Workflow with Grunt.js

All the repetitive chores...● Compile LESS, SASS,

Stylus, CoffeeScript, etc.

● JSHint / JSLint● Concatenate and

minify scripts and styles

● Run with different settings for development and “builds”

● Automatically generate sprite sheets

● Deploy using git, ftp, scp or rsync

● Live reload in the browser

● Compress images

Page 5: Automate your WordPress Workflow with Grunt.js

Grunt uses Plugins

Page 6: Automate your WordPress Workflow with Grunt.js

“contrib-” = officially maintained

● contrib-watch● contrib-jshint● contrib-clean● contrib-copy● contrib-uglify● contrib-imagemin● contrib-concat

● contrib-less● contrib-sass● contrib-compass● contrib-stylus● contrib-livereload● contrib-cssmin● contrib-htmlmin

Page 7: Automate your WordPress Workflow with Grunt.js

Step 1Install Node.js & NPM: http://nodejs.

org/

Page 8: Automate your WordPress Workflow with Grunt.js

Step 2Make a basic package.json

Page 9: Automate your WordPress Workflow with Grunt.js

A basic pa

Page 10: Automate your WordPress Workflow with Grunt.js

Install the Grunt-CLI globally

Page 11: Automate your WordPress Workflow with Grunt.js

Install grunt in your project folder

Page 12: Automate your WordPress Workflow with Grunt.js

Using “--save-dev” automatically updates package.json

Page 13: Automate your WordPress Workflow with Grunt.js

Install some plugins… (with --save-dev)

Page 14: Automate your WordPress Workflow with Grunt.js

All NPM packages (Grunt and it’s plugins) get installed in `node_modules/`

Add this directory to .gitignore to prevent repo bloatNew developers can install all dependencies with `npm install` in the

project dir

Page 15: Automate your WordPress Workflow with Grunt.js

Gruntfile.js — the secret sauce(example from http://mattbanks.me/grunt-wordpress-development-deployments/)

fancy trick to autoload all grunt plugins

Page 16: Automate your WordPress Workflow with Grunt.js

from

http

://ju

stin

klem

m.c

om/g

runt

-bow

er-w

ordp

ress

-them

es/

Page 17: Automate your WordPress Workflow with Grunt.js
Page 18: Automate your WordPress Workflow with Grunt.js

WordPress

Page 19: Automate your WordPress Workflow with Grunt.js
Page 20: Automate your WordPress Workflow with Grunt.js

This is not ideal...

Page 21: Automate your WordPress Workflow with Grunt.js

For theme and plugin development, keep grunt stuff in the theme/plugin folder

Page 22: Automate your WordPress Workflow with Grunt.js

● Use one Gruntfile for the entire site● Combine CSS and JS from multiple plugins and

your theme — speeds up your site!

Best when:● you have complete control over site code● you want to use grunt for deployment

Supercharge your whole site

Page 23: Automate your WordPress Workflow with Grunt.js

Grunt stuff is in the top-level folderwith the other developer files

This whole foldercan be safelydeployed withoutwriting out longlists of ignored filesfor your deploy system

WordPress in a subdirectory

Page 24: Automate your WordPress Workflow with Grunt.js

Let’s do it live...

Page 25: Automate your WordPress Workflow with Grunt.js

Other Tools

● Bower● Composer● Yeoman● roots.io● WP Stack