The document discusses automating front-end development workflows. It recommends using tools like LiveReload, BrowserSync, and npm to make front-end changes and testing easier. LiveReload and BrowserSync allow automatic refreshing of pages when files change. Npm is used to install node packages that help set up local development environments and manage dependencies. The document also suggests using application launchers to quickly search files and launch applications. This helps improve productivity by streamlining common front-end tasks like making changes, previewing updates, and finding errors.
12. Kitt Hodsden • @kitt • http://ki.tt/cfo
node & ruby
12
We need node and ruby to use the tools we’re going to talk about.
13. Kitt Hodsden • @kitt • http://ki.tt/cfo 13
Setup node by downloading the installer and running it.
http://nodejs.org
14. Kitt Hodsden • @kitt • http://ki.tt/cfo 14
# mac / linux
$ which ruby
/usr/local/bin/ruby
$ ruby --version
ruby 2.0.0p195
# windows
> where ruby
C:Ruby200binruby.exe
> ruby --version
ruby 2.0.0p451
Yay! Sass installed!See if you already have ruby installed
15. Kitt Hodsden • @kitt • http://ki.tt/cfo 15
HOMEBREW
http://mxcl.github.com/homebrew/
$ brew install ruby
RVM RUBY VERSION MANAGER
https://rvm.io/rvm/install
Install ruby in different ways on OSX
OSX
16. Kitt Hodsden • @kitt • http://ki.tt/cfo 16
HOMEBREW
http://mxcl.github.com/homebrew/
$ brew install ruby
RVM RUBY VERSION MANAGER
https://rvm.io/rvm/install
Install ruby in different ways on OSX
OSX
17. Kitt Hodsden • @kitt • http://ki.tt/cfo 17
https://unfiniti.com/software/mac/jewelrybox
Ruby on OSX, I recommend JewelryBox, too.
18. Kitt Hodsden • @kitt • http://ki.tt/cfo 18
APT / YUM
$ sudo apt-get install ruby1.9.1
$ sudo yum install ruby1.9.1
RVM RUBY VERSION MANAGER
https://rvm.io/rvm/install
Install ruby in different ways on Linux
Linux
19. Kitt Hodsden • @kitt • http://ki.tt/cfo 19
APT / YUM
$ sudo apt-get install ruby1.9.1
$ sudo yum install ruby1.9.1
RVM RUBY VERSION MANAGER
https://rvm.io/rvm/install
Install ruby in different ways on Linux
Linux
20. Kitt Hodsden • @kitt • http://ki.tt/cfo 20
RUBYINSTALLER
http://rubyinstaller.org/downloads/
PIK
https://github.com/vertiginous/pik
Install ruby in different ways on Windows
Windows
21. Kitt Hodsden • @kitt • http://ki.tt/cfo 21
RUBYINSTALLER
http://rubyinstaller.org/downloads/
PIK
https://github.com/vertiginous/pik
Install ruby in different ways on Windows
Windows
CYGWIN
http://cygwin.com
24. Kitt Hodsden • @kitt • http://ki.tt/cfo 24
Automate All the Front-End
Development Things!
25. Kitt Hodsden • @kitt • http://ki.tt/cfo
Make your Front-End
Workflow AWESOME
25
26. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Embrace the DRY principle
26
Guiding principles of making our workflows AWESOME
27. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Embrace the DRY principle
2. Make changes easy
27
Guiding principles of making our workflows AWESOME
28. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Embrace the DRY principle
2. Make changes easy
3. Make finding mistakes easy
28
Guiding principles of making our workflows AWESOME
29. Kitt Hodsden • @kitt • http://ki.tt/cfo
Implement a design or prototype
29
What magic do we do?
30. Kitt Hodsden • @kitt • http://ki.tt/cfo
Implement a design or prototype
Update the designs
30
What magic do we do?
31. Kitt Hodsden • @kitt • http://ki.tt/cfo
Implement a design or prototype
Update the designs
Make sure it works in all browsers
31
What magic do we do?
32. Kitt Hodsden • @kitt • http://ki.tt/cfo
Implement a design or prototype
Update the designs
Make sure it works in all browsers
Make it faster
32
What magic do we do?
33. Kitt Hodsden • @kitt • http://ki.tt/cfo
Implement a design or prototype
Update the designs
Make sure it works in all browsers
Make it faster
33
What magic do we do?
48. Kitt Hodsden • @kitt • http://ki.tt/cfo 48
<script>document.write('<script src="http://'
+ (location.host || 'localhost').split(':')
[0] + ':35729/livereload.js?snipver=1"></' +
'script>')</script>
If you don’t use browser plugins, you need this JS for LiveReload
49. Kitt Hodsden • @kitt • http://ki.tt/cfo 49
<cfoutput>
<script>document.write('<script src="http://'
+ (location.host || 'localhost').split(':')
[0] + ':35729/livereload.js?snipver=1"></' +
'script>')</script>
</cfoutput>
If you don’t use browser plugins, you need this JS for LiveReload
57. Kitt Hodsden • @kitt • http://ki.tt/cfo 57
Open a new terminal or command window
58. Kitt Hodsden • @kitt • http://ki.tt/cfo 58
In OSX, drag and drop the folder into the terminal window for the path.
59. Kitt Hodsden • @kitt • http://ki.tt/cfo 59
In Windows, use right click cut and paste
60. Kitt Hodsden • @kitt • http://ki.tt/cfo 60
// save this into run-server.js
var connect = require('connect');
connect.createServer(
connect.static(__dirname)
).listen(8080);
If you don’t have a local development environment, use this run-server.js
61. Kitt Hodsden • @kitt • http://ki.tt/cfo 61
$ npm install connect
...
$ node run-server.js
# open http://localhost:8080/index.html
# control-c to stop
If you don’t have a local development environment, install the connect package
62. Kitt Hodsden • @kitt • http://ki.tt/cfo 62
> npm install connect
...
> node run-server.js
# open http://127.0.0.1:8080/index.html
# control-c to stop
If you don’t have a local development environment on Windows, install the connect package
63. Kitt Hodsden • @kitt • http://ki.tt/cfo 63
You can accept this local JS file running on node, turn it off later!
64. Kitt Hodsden • @kitt • http://ki.tt/cfo
http://localhost:8080/index.html
http://127.0.0.1:8080/index.html
64
You can see the temporary site running locally!
70. Kitt Hodsden • @kitt • http://ki.tt/cfo 70
$ browser-sync init
[BS] Config file created (bs-config.js)
[BS] To use it, in the same directory run: browser-sync
$
76. Kitt Hodsden • @kitt • http://ki.tt/cfo 76
$ browser-sync start
[BS] Copy the following snippet into your website, just before the closing </
body> tag
<script src='//192.168.5.6:3000/socket.io/socket.io.js'></script>
<script>var ___socket___ = io.connect('http://192.168.5.6:3000');</script>
<script src='//192.168.5.6:3001/client/browser-sync-client.0.7.0.js'></script>
[BS] Watching files...
109. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Find grunt plugin*
2. Install with npm install --save-dev
3. Add the task to our Gruntfile.js file
4. Add the tasks to a command
5. Run the command
...
7. Profit!
*write if you need to
109
How to add a task to grunt
110. Kitt Hodsden • @kitt • http://ki.tt/cfo
http://npmjs.org
110
Where to find node and grunt packages
111. Kitt Hodsden • @kitt • http://ki.tt/cfo
“grunt browser-sync”
111
What I searched for on npmjs.org
112. Kitt Hodsden • @kitt • http://ki.tt/cfo
THIS IS OKAY.
112
113. Kitt Hodsden • @kitt • http://ki.tt/cfo 113
Check for current state before downloading.
129. Kitt Hodsden • @kitt • http://ki.tt/cfo 129
1. Find grunt plugin*
2. Install with npm install --save-dev
3. Add the task to our Gruntfile.js file
4. Add the tasks to a command
5. Run the command
...
7. Profit!
*write if you need to
130. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Embrace the DRY principle
2. Make changes easy
3. Make finding mistakes easy
130
Guiding principles of making our workflows AWESOME
132. Kitt Hodsden • @kitt • http://ki.tt/cfo 132
...
// load all the grunt modules instead of one each line
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.registerTask('checkjs', ['jshint']);
grunt.registerTask('watchjs', ['jshint', 'watch']);
grunt.registerTask('gruntjs', ['jshint:gruntfile', 'watch']);
133. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Embrace the DRY principle
2. Make changes easy
3. Make finding mistakes easy
133
Guiding principles of making our workflows AWESOME
232. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Watch for file changes
2. Compile our Sass to CSS
3. Refresh the browser on change
232
What we want grunt to do.
256. Kitt Hodsden • @kitt • http://ki.tt/cfo 256
This works in > Firefox 29, right click to show CSS
257. Kitt Hodsden • @kitt • http://ki.tt/cfo 257
1. Reduce file sizes
2. Reduce the number of files
3. Reduce content rendering time
258. Kitt Hodsden • @kitt • http://ki.tt/cfo
Don’t nest more than 3 deep
258
http://css-tricks.com/sass-style-guide/
259. Kitt Hodsden • @kitt • http://ki.tt/cfo
Avoid using tag selectors
Use class selectors if you can.
259
https://developers.google.com/speed/docs/best-practices/rendering
260. Kitt Hodsden • @kitt • http://ki.tt/cfo
1. Embrace the DRY principle
2. Make changes easy
3. Make finding mistakes easy
260
Guiding principles of making our workflows AWESOME
271. Kitt Hodsden • @kitt • http://ki.tt/cfo
Say Goodbye to “It works
on my machine” with Chef
and Vagrant.
Curt Gratz, 3pm this room
271
272. Kitt Hodsden • @kitt • http://ki.tt/cfo 272
What magic do we do?
Implement a design or prototype
Update the designs
Make sure it works in all browsers
Make it faster
273. Kitt Hodsden • @kitt • http://ki.tt/cfo
From the beginning!
273
274. Kitt Hodsden • @kitt • http://ki.tt/cfo
Faster HTML
274
283. Kitt Hodsden • @kitt • http://ki.tt/cfo 283
# use a generator
$ yo webapp
# start the server
$ grunt server
# run tests
$ grunt test
# run default
$ grunt
284. Kitt Hodsden • @kitt • http://ki.tt/cfo 284
# download new generator
$ npm install generator-gruntplugin
# run the generator
$ yo gruntplugin
285. Kitt Hodsden • @kitt • http://ki.tt/cfo 285
# download new generator
$ npm install generator-gruntfile
# run the generator
$ yo gruntfile
286. Kitt Hodsden • @kitt • http://ki.tt/cfo 286
Lots of generators available
http://yeoman.io/official-generators.html
287. Kitt Hodsden • @kitt • http://ki.tt/cfo 287
# download new generator
$ npm install generator-generator
# create the directory
$ mkdir generator-bigred && cd $_
# run the generator
$ yo generator
289. Kitt Hodsden • @kitt • http://ki.tt/cfo
Wow, that was fast.
289
290. Kitt Hodsden • @kitt • http://ki.tt/cfo
I skipped over
Bundler
Managing what ruby gems you have installed
http://bundler.io/
Creating your own Grunt tasks
http://gruntjs.com/creating-tasks
Bower
http://bower.io/
290