automate all the things with grunt

21
Automate All the Things with Grunt

Upload: sheelah-brennan

Post on 22-Mar-2017

237 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Automate All the Things with Grunt

Automate All the Things with Grunt

Page 2: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com2

About Me

@sheelah_b

http://sheelahb.com

2

Page 3: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com3

What is Grunt?

Page 4: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com4

• Compile Sass or Less into CSS

• Automatically reload content after changes to CSS, JavaScript, HTML, or other assets

• Lint, concatenate, and compress JavaScript files

• Optimize images and SVG files

• Automate performance testing

What can it do?

Page 5: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com5

• Install Node.js (https://nodejs.org/)

• Install Grunt CLI (npm install -g grunt-cli)

Grunt Prerequisites

Page 6: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com6

• Generate a package.json file (npm init)

• Install Grunt in your project (npm install grunt --save-dev)

• Barebones Gruntfile.js

Grunt Setup within Project

Page 7: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com7

• Grunt watch plugin (npm install grunt-contrib-watch --save-dev)

• Grunt libsass plugin (npm install grunt-sass --save-dev)

Starter Grunt Plugins

Page 8: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com8

• Enable source map generation to be able to view Sass/Less source files in the browserhttp://www.sitepoint.com/using-source-maps-debug-sass-chrome/

#quicktip

Page 9: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com9

BrowserSync Plugin

Page 10: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com10

• Synchronized cross-device and cross-browser testing FTWnpm install grunt-browser-sync --save-dev http://www.browsersync.io/

BrowserSync Plugin

Page 11: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com11

• Automatically adds vendor prefixes where needed in your CSSnpm install grunt-postcss autoprefixer --save-dev

Autoprefixer Plugin

Page 12: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com12

• No need to manually include loadNpmTasks entries for each task (npm install load-grunt-tasks --save-dev)

• Get time metrics for each task (npm install --save-dev time-grunt)

Automatically Load Tasks

Page 13: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com13

• JSHint (http://jshint.com/)npm install grunt-contrib-jshint --save-dev npm install jshint-stylish --save-dev

JavaScript-Related Plugins

Page 14: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com14

• Concatnpm install grunt-contrib-concat --save-dev

• Uglifynpm install grunt-contrib-uglify --save-dev

JavaScript-Related Plugins

Page 15: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com15

• Imageminnpm install grunt-contrib-imagemin --save-dev

Image Optimization Plugin

Page 16: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com16

• CSS optimizations (grunt-criticalcss)https://github.com/addyosmani/critical-path-css-tools

• Performance testing (grunt-perfbudget) using WebPageTest.orghttp://www.sitepoint.com/automate-performance-testing-grunt-js/

Taking it up a Level

Page 17: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com17

• Unit testing (Ex. grunt-contrib-jasmine)

• Internationalization and localization

Taking it up a Level

Page 18: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com18

• Pull down the git repo

• Install the required Grunt plugins (npm install)

Contributing to an Existing Project Using Grunt

Page 19: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com19

• Gulp (http://gulpjs.com/)

• CodeKit (Gui, Mac only)

• Prepros (Gui, Windows only)

Grunt Alternatives

Page 20: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com20

• https://css-tricks.com/grunt-people-think-things-like-grunt-weird-hard/

• https://scotch.io/tutorials/a-simple-guide-to-getting-started-with-grunt/

• http://gruntjs.com/getting-started/

References

Page 21: Automate All the Things with Grunt

Sheelah Brennan http://sheelahb.com

@sheelah_b

21

Questions?