frontend workflow

201
AUTOMATING WORKFLOW IMPROVING FRONT-END HAPPINESS WITH BETTER TOOLING

Upload: delphicon

Post on 12-Apr-2017

382 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Frontend Workflow

AUTOMATING W ORK F LOWIMPROVING FRONT-END HAPPINESS WITH BETTER

TOOLING

Page 2: Frontend Workflow

Trying to develop for the web today is a little like..

Page 3: Frontend Workflow
Page 4: Frontend Workflow

O ur tooling landscape is getting more complex.

Page 5: Frontend Workflow

Boilerplate Abstractions F rameworks Testing

Docs Workflow Dependency management

Performance optimization Build

C ontinuous Integ ration Deployment Version control

Page 6: Frontend Workflow

OMG. W H AT IS THAT?

Page 7: Frontend Workflow

The second is..

Choose tools you’ll use.

Page 8: Frontend Workflow

Time is a key factor in staying productive.

Page 9: Frontend Workflow
Page 10: Frontend Workflow

A utomate repetitive tasks to stay effective.

Page 11: Frontend Workflow
Page 12: Frontend Workflow

Automation isn’t about being lazy. It’s about being efficient.

Page 13: Frontend Workflow

The rig ht tools make the difference between an artist and a craftsman.

Page 14: Frontend Workflow
Page 15: Frontend Workflow

The averag e front-end workflow today

Page 16: Frontend Workflow

SetupScaffolding Download libraries Download templatesDownload frameworks

Page 17: Frontend Workflow

DevelopWatch Sass / Less / Stylus Watch Co ffeeScriptWatch Jade / Haml LiveReloadJS / C SS Linting

Page 18: Frontend Workflow

Code linting Running unit tests Compile everythingMinify and concatenate Generate images / icons Optimize performance HTTP ServerDeployment Build

Page 19: Frontend Workflow

A utomate this workflow for

simple projects

Page 20: Frontend Workflow

Workflow tools

bit.ly/codekit

Page 21: Frontend Workflow

bit.ly/prepros

W in/Mac

Page 22: Frontend Workflow

koala-app.com

W/M/L

Page 23: Frontend Workflow

mixture.io

W in/Mac

Page 24: Frontend Workflow

So happy.I may just cry.

Page 25: Frontend Workflow

Iterative improvement.

Page 26: Frontend Workflow

First do it.Then do it rig ht. Then do it better.

Page 27: Frontend Workflow
Page 28: Frontend Workflow

better?

Page 29: Frontend Workflow

A utomate workflow for

all types of projects.

Page 30: Frontend Workflow
Page 31: Frontend Workflow

Scaffold, write less with YoBuild, preview and test with Grunt Manage dependencies with Bower

Page 32: Frontend Workflow

F lexibility to customize your setup as much as you desire.

Page 33: Frontend Workflow

L imit the time spent writing boilerplate.

Page 34: Frontend Workflow

Improve your productivity and delight during development.

Page 35: Frontend Workflow
Page 36: Frontend Workflow

Helps run repetitive tasks.

Page 37: Frontend Workflow

Linting Co mpiling Minification Testing Co nversionDocumentation Deployment And more

Page 38: Frontend Workflow

Alternative to Rake/Cake/Make/Ant

Page 39: Frontend Workflow

Huge ecosystem.

Page 40: Frontend Workflow

Fantastic for developers and desig ners.

Page 41: Frontend Workflow

touch package.json Gruntfile.js

Page 42: Frontend Workflow

package.json

Page 43: Frontend Workflow

{"name": "awesome-app","version": "0.0.1", "devDependencies": {

"grunt": "~0.4.1","grunt-contrib-jshint": "~0.6.3", "grunt-contrib-uglify": "~0.2.0"

}}

Specify Grunt plugins and metadata.

Page 44: Frontend Workflow

Gruntfile.js

Page 45: Frontend Workflow

module.exports = function(grunt){ grunt.initConfig({

uglify: { build: {

src: dest:

'app.js', 'build/app.min.js'}

{ all: ['**/*.js']}},jshint:

});

grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.registerTask('default', ['jshint', 'uglify']);

};

Config tasks and load plugins

Page 46: Frontend Workflow

$ npm install -g grunt-cli

Page 47: Frontend Workflow

$ npm install

Page 48: Frontend Workflow

$ grunt

Running “jshint:all” (jshint) task Running “uglify:build” (uglify) task Done.

Page 49: Frontend Workflow

Not bad!

Page 50: Frontend Workflow

$ npm install grunt-<taskname> --save-dev

Page 51: Frontend Workflow

task tip

grunt-responsive-imagesCreate multi-resolution images from a directory for src-set/srcN

bit.ly/grunt-resp

Page 52: Frontend Workflow

task tip

grunt-contrib-imageoptim

Lower page-weight by applying optimizations to

JPG/PNG/Gif

bit.ly/grunt-image

Page 53: Frontend Workflow

speed tip

grunt-concurrentSpeed up build time by concurrently running tasks like Sass and Coffee.

bit.ly/grunt-conc

Page 54: Frontend Workflow

speed tip

grunt-newerRun tasks on only source

files modified since the last run.

bit.ly/grunt-newer

Page 55: Frontend Workflow

A first look at something new I’ve been hacking on

Page 56: Frontend Workflow

grunt-uncssRemove unused CSS across your project at build time.

bit.ly/uncss

Page 57: Frontend Workflow

A few weeks ago..

Page 58: Frontend Workflow
Page 59: Frontend Workflow

Get audits for unused C SS in your pag e with DevTools

Page 60: Frontend Workflow

Chrome DevTools A udits

Page 61: Frontend Workflow

g runt-uncss can remove unused C SS at build time

Page 62: Frontend Workflow

120KB

11KB

W hat about Bootstrap alone?

Page 63: Frontend Workflow

Very early days, but 120KB down to 1 1 K B of C SS .

Page 64: Frontend Workflow
Page 65: Frontend Workflow

A package manager for the web.

Page 66: Frontend Workflow

1.That lib is 6 months old? Better update.2. Open up the site3. Download the lib4. Copy from ~/Downloads5. Paste to app folder6. W ire in with script tag s

The old way of doing thing s.

Page 67: Frontend Workflow

New hotness.

Page 68: Frontend Workflow

$ npm install -g bower

Page 69: Frontend Workflow

$ bower search

Page 70: Frontend Workflow

$ bower search angularSearch results:

angular git://github.com/angular/bower-angular.gitangular-mocks git://github.com/angular/bower-angular-mocks.git angular-resource git://github.com/angular/bower-angular-

resource.gitangular-cookies git://github.com/angular/bower-angular-cookies.git angular-sanitize git://github.com/angular/bower-angular-

sanitize.gitangular-bootstrap git://github.com/angular-ui/bootstrap-bower.git

........

Page 71: Frontend Workflow

$ bower install

Page 72: Frontend Workflow

$ bower install angular --save-devbower install angular#1.0.8

angular#1.0.8 app/bower_components/angular

Page 73: Frontend Workflow

$ bower install

$ bower install <package>

$ bower install <package>#<version>

$ bower install <name>=<package>#<version>

Page 74: Frontend Workflow

$ bower list

Page 75: Frontend Workflow

$ bower list Checking for new versions of

the projectbower check-new dependencies..testapp#0.0.0 /Users/addyo/projects/testapp├ ─ ─ angular#1.0.8 (latest is 1.2.0-rc.3)├ ─ ┬ bootstrap#3.0.0│ └ ─ ─ jquery#1.9.1 (2.0.3 available)├ ─ ─ jquery#1.9.1 (latest is 2.0.3)└ ─ ─ modernizr#2.6.2

Page 76: Frontend Workflow

Runs over: Git HTTP(s)Zip npm

Page 77: Frontend Workflow

You can even wire up deps from the command-line!

Page 78: Frontend Workflow

grunt-bower-install

bit.ly/grunt-bower

Page 79: Frontend Workflow

$ npm install grunt-bower install --save-dev$ bower install jquery --save$ grunt bower-install

Page 80: Frontend Workflow

No more worrying about script tags!

Page 82: Frontend Workflow

bit.ly/bowersearch

Page 83: Frontend Workflow
Page 84: Frontend Workflow

Yo is your gateway to this magical new world.

Page 85: Frontend Workflow

It scaffolds out boilerplate.

Page 86: Frontend Workflow

Can prescribe helpful Grunt tasks.

Page 87: Frontend Workflow

C an automatically install dependencies you need.

Page 88: Frontend Workflow

$ npm install -g yo

Page 89: Frontend Workflow

This installs yo, g runt and bower for you.

Page 90: Frontend Workflow

$ yo

[?] What would you like to do?›❯ Install a generatorRun the Angular generator (0.4.0) Run the Backbone generator (0.1.9) Run the Blog generator (0.0.0)Run the jQuery generator (0.1.4) Run the Gruntfile generator (0.0.6)

(Move up and down to reveal more choices)

Page 91: Frontend Workflow

$ yo[?] What would you like to do? Install a generator [?] Search NPM for generators: jquery[?] Here's what I found. Install one?›❯ generator-jquery-boilerplate generator-jquery-mobile Search again

Return home

Page 92: Frontend Workflow

$ yo jquery-boilerplatecreate .jshintrccreate CONTRIBUTING.md create Gruntfile.jscreate HISTORY.mdcreate boilerplate.jquery.json create demo/index.htmlcreate dist/jquery.boilerplate.js create dist/jquery.boilerplate.min.js create package.jsoncreate src/jquery.boilerplate.coffee create src/jquery.boilerplate.js

Page 93: Frontend Workflow

Boom. You just created a jQuery plugin.

Page 94: Frontend Workflow

Installing a custom generator.

Page 95: Frontend Workflow

$ npm install generator-bootstrap -g

Page 96: Frontend Workflow

$ yo bootstrap

In what format would you like the Twitter Bootstrap stylesheets? (Use arrow keys)›❯ css sass less stylus

Page 97: Frontend Workflow

$ npm install generator-webapp -g

Page 98: Frontend Workflow

$ yo webapp

Out of the box I include H5BP and jQuery. [ ? ] What more would you like?

›❯ Bootstrap for Sass RequireJS Modernizr

Page 99: Frontend Workflow
Page 100: Frontend Workflow

Boilerplate - H5BP, Bootstrap, Modernizr Abstractions - optionally Sass, C offeeScript, grunt- bower-install available by default.Performance optimization - optimize images, scripts, stylesheets, get lean Modernizr builds, concurrently run all of these tasks at build time. Testing and build process - Mocha, Jasmine, PhantomJS

Boom. Just created a webapp!

Page 101: Frontend Workflow

$ grunt server

Page 102: Frontend Workflow

You can now edit and L iveReload!

Page 103: Frontend Workflow

Make changes. Save. Browser automatically refreshes.

Page 104: Frontend Workflow

F antastic for g etting a real-time view of application state.

Page 105: Frontend Workflow

Edits can also refresh all your devices. Instant real-device previews.

Page 106: Frontend Workflow

C ross-device live reload

bit.ly/gruntsync

Page 107: Frontend Workflow

W hat about frameworks?

Page 108: Frontend Workflow

$ npm install generator-angular -g

Page 109: Frontend Workflow

$ yo angular

[?] Would you like to include Bootstrap? (Y/n)

Page 110: Frontend Workflow

$ yo angular

[?] Would you like to include Bootstrap? (Y/n) [?] Would you like to use the SCSS version?

Page 111: Frontend Workflow

$ yo angular

[?] Would you like to include Bootstrap? (Y/n) [?] Would you like to use the SCSS version? [?] Which modules would you like to include? (Press <space> to select)›❯ angular-resource.jsangular-

cookies.js angular-sanitize.js

Page 112: Frontend Workflow
Page 113: Frontend Workflow

$ yo angular:view user

create

app/views/user.html

Page 114: Frontend Workflow

$ yo angular:controller user

create app/scripts/controllers/user.js create test/spec/controllers/user.js

Page 115: Frontend Workflow

$ yo angular:directive mydirective

create app/scripts/directives/mydirective.js create test/spec/directives/mydirective.js

Page 116: Frontend Workflow

$ bower install angular-local-storage

create app/scripts/directives/mydirective.js create test/spec/directives/mydirective.js

Page 117: Frontend Workflow

You just created an A ng ular app with dependencies

Page 118: Frontend Workflow

$ yo express-angular

AngularJS + Express backend

Page 119: Frontend Workflow

Generators also available for:

Backbone Ember Polymer Flight CanJS& many other frameworks.

Page 120: Frontend Workflow

$ yo jekyllrbTell us a little about yourself. ☛ [?] Name: Erik Kotsuba[?] Email: [email protected][?] GitHub username: eko24[?] Twitter username: @eko24ive

Wire tools and preprocessors. ☛ [?] CSS preprocessor: Sass[?] Use Autoprefixer? Yes [?] Javascript preprocessor: Coffeescript› ❯ None

Page 121: Frontend Workflow

$ yo chrome-extension[?] What would you like to call this extension? [?] How would you describe it?[?] Would you like more UI Features?›❯ Options Page

Content Scripts Omnibox

[?] Would you like to use permissions? (Press <space> to select)›❯ Tabs

BookmarksCookies History Management

Page 122: Frontend Workflow

$ yo mobileBootstrap 3, TopCoat, F oundation, Pure Generates responsive images Generates site screenshotsRemoves 30 0 ms delay on touch Boilerplate for Fullscreen API Integrated BrowserStack testing Polyfill for async localStorag e and more.

bit.ly/yomobile

Page 124: Frontend Workflow

Generator search

Page 126: Frontend Workflow

Work less. Do more.

Make awesome.

Page 127: Frontend Workflow

How can we improve the rest of your workflow?

Page 128: Frontend Workflow

Learn to love the command-line

Page 129: Frontend Workflow

It isn’t scary. People know how to use PhotoShop’s 30 0 0

buttons.That’s scary!

Page 130: Frontend Workflow

@climagic

Page 131: Frontend Workflow

Do things more quickly.

Page 132: Frontend Workflow

Alfred.app

Page 133: Frontend Workflow

Alfred Workflows

Find apps, files

Find packages on npm

Build tasks

bit.ly/alfredworkflows

Page 134: Frontend Workflow

Alfred Workflowsbit.ly/alfredworkflows

Find documentation on Dash

Browser compatibility search

Font awesome search

Page 135: Frontend Workflow

AutomatorPoint-and-click automation of

repetitive tasks

Page 136: Frontend Workflow

bit.ly/macrorecorder

Page 137: Frontend Workflow

Next, let’s look at your editor.

Page 138: Frontend Workflow

Know yours inside out.

Page 139: Frontend Workflow

Shortcuts are incredibly powerful.

Page 140: Frontend Workflow

Sublime AutoprefixerWrite CSS without the

prefixes!

bit.ly/autoprefixer

Page 141: Frontend Workflow

Emmet (Z en C oding)

bit.ly/emmet-sublime

Page 142: Frontend Workflow

Emmet (Z en C oding)

emmet.io/

Page 143: Frontend Workflow

STProjectMakerEasily reuse your

boilerplates

bit.ly/stprojectmaker

Page 144: Frontend Workflow

Sublime TernJSSmarter code completion, contextual jump to

definition.

bit.ly/sublime-tern

Page 145: Frontend Workflow

Develop and debug in the browser

Page 146: Frontend Workflow

Chrome DevToolsAn improved find and fix workflow.

devtools.chrome.com

Page 147: Frontend Workflow

WorkspacesAdd and edit local projects. Breakpoints persist. Debug

in-place.

Page 148: Frontend Workflow

New! C reate New Files

Page 149: Frontend Workflow

Sass Source Maps

Page 150: Frontend Workflow

New! L ess Source Maps

Page 151: Frontend Workflow

New! C SS Pretty-printing

Page 152: Frontend Workflow

New! Ignoring library code

Page 153: Frontend Workflow

New! DevTools Terminalnpm, git and all your favorite cli tools with this extension

Page 154: Frontend Workflow

bit.ly/devtools-terminal

Page 155: Frontend Workflow

W hat about better integ ration between tools?

Page 156: Frontend Workflow

bit.ly/sublime-inspector

Sublime Web Inspector

Debugger. Breakpoints. Console. Evaluate call frames.

Page 157: Frontend Workflow

Emmet LiveStyleEdit CSS. See changes live in Chrome *without* a

browser refresh.

livestyle.emmet.io

Page 158: Frontend Workflow

Sublime jsRunRun JS in Chrome from

Sublime

bit.ly/sublime-jsrun

Page 159: Frontend Workflow

Synchronized cross-device testing

Page 160: Frontend Workflow

Re-checking your site on mobile is a pain

Page 161: Frontend Workflow

Navig ate all devices to the same URL

Page 162: Frontend Workflow

A lo-fi, free option

Remote Preview

Page 163: Frontend Workflow

Remote Preview

◦ [+] Free!◦ [-] Loads page into iframe◦ [-] Requires user to type url in page◦ [+] Central place to change url to load into

iframe after initial set-up

bit.ly/remotepreview

Page 164: Frontend Workflow

Synchronize navig ation & get screenshots.

Page 165: Frontend Workflow

Adobe Edg e Inspect C C

Page 166: Frontend Workflow
Page 167: Frontend Workflow

Adobe Edge Inspect

◦ [-] One device at a time◦ [-] Displays site in a WebView◦ [+] Supports live reload◦ [+] Extension to load any page you view in

Chrome◦ [-] Can’t account for localhost (i.e. switch to ip

addr. of machine on local network)◦ [+] Remote Inspect via Weinre

bit.ly/edgeinspect

Page 168: Frontend Workflow

Refresh all devices on edit

Page 169: Frontend Workflow

Grunt + LiveReload

Page 170: Frontend Workflow

Grunt + LiveReload

◦ [+] Free!◦ [+] Easily see how each change you save looks across

devices◦ [+] Works with any modern mobile browser◦ [-] Requires you to use Grunt for your build process

bit.ly/gruntsync

Page 171: Frontend Workflow

Synchronize scrolls, c licks, interactions as well as navigation

Page 172: Frontend Workflow

Mobile Debugging

Page 173: Frontend Workflow

DevTools Remote Debugging

Page 174: Frontend Workflow

New! RAW USB Debugging

Page 175: Frontend Workflow

jsConsole

bit.ly/jsconsole

Page 176: Frontend Workflow

js Hybugger

jshybugger.com

Page 177: Frontend Workflow

Visual reg ression testing

Page 178: Frontend Workflow

Wraith

bit.ly/wraithapp

Page 179: Frontend Workflow

Huxley

bit.ly/huxleyapp

Page 180: Frontend Workflow

PhantomCSS

bit.ly/phantomcss

Page 181: Frontend Workflow

Simulate real-network conditions

Page 182: Frontend Workflow

charlesproxy.com

Page 183: Frontend Workflow

Network Link C onditioner

Page 184: Frontend Workflow

slowyapp.com

Page 185: Frontend Workflow

Fiddler

fiddler2.com

Page 186: Frontend Workflow

Simulators & Emulators

Page 187: Frontend Workflow

Open Device Labs

Page 188: Frontend Workflow

Screenshots or live testing?

Page 189: Frontend Workflow

Simulators

bit.ly/simulatorlist

Massive, well-maintained list of emulators & simulators available

Page 190: Frontend Workflow

A re emulators enough?

Page 191: Frontend Workflow

Do I even need an emulator?

Chrome DevTools Overrides

Page 192: Frontend Workflow

Emulate touch events

Page 193: Frontend Workflow

Emulate screens

Page 194: Frontend Workflow

Emulate device orientation

Page 195: Frontend Workflow

Emulate Geolocation

Page 196: Frontend Workflow

To learn more checkout our DevTools docs at devtools.chrome.com

Page 197: Frontend Workflow

If you aren't using automation, you are working too hard

Remember

Page 198: Frontend Workflow

Use tools. not rules.

Page 199: Frontend Workflow

Improve your developer happiness

Page 200: Frontend Workflow

Thank you.

Page 201: Frontend Workflow

Questions ?