Upgrade to Pro — share decks privately, control downloads, hide ads and more …

StrasbourgJS - Be lazy

Soulou
March 02, 2015

StrasbourgJS - Be lazy

Don't repeat yourself and automatize everything. Introduction to gulp and discussion about node apps deployment.

Soulou

March 02, 2015
Tweet

More Decks by Soulou

Other Decks in Technology

Transcript

  1. 1. Don't do things Be lazy! 2. Build flexible apps

    Development and Production are equal
  2. 1. Don't do things Be lazy! 2. Build flexible apps

    Development and Production are equal 3. Efficient deployments ‘‘ Deploy friday 6pm... let's do it! ’’
  3. 3. Autoreload $ [sudo] npm install -g supervisor $ supervisor

    server.js Alternatives: “forever”, “nodemon”
  4. 6. Automatize assets management $ npm install gulp --save OR

    (but don't start a project with it) – $ npm install grunt --save
  5. 6. Automatize assets management var gulp = require("gulp"), stylus =

    require("gulp-stylus") gulp.task("stylus", function() { return gulp.src("assets/stylesheets/*.styl") .pipe(stylus()) .pipe(gulp.dest('public/styles')); });
  6. 6. Automatize assets management var gulp = require("gulp"), stylus =

    require("gulp-stylus"), prefixer = require(“gulp-autoprefixer”) gulp.task("stylus", function() { return gulp.src("assets/stylesheets/*.styl") .pipe(stylus()) .pipe(prefixer()) .pipe(gulp.dest('public/styles')); });
  7. 8. Use NPM scripts { … “scripts”: { "postinstall": "npm

    run gulp", "gulp": "gulp stylus", "start": "node index.js" } … }
  8. 9. Correctly handle shutdown { … “scripts”: { "postinstall": "npm

    run gulp", "gulp": "gulp stylus", "start": "node index.js" } … }
  9. 10. Deploy many times → One command, nothing else $

    git push <dest> <ref> dest: PaaS | Continuous Integration | Your Server