mugli
2/17/2014 - 5:54 PM

Gulpfile.express.js

var gulp = require('gulp');

// Let's make things more readable by
// encapsulating each part's setup
// in its own method
function startExpress() {

  var express = require('express');
  var app = express();
  app.use(express.static(__dirname));
  app.listen(4000);
}

gulp.task('default', function () {

  startExpress();
});
var gulp = require('gulp');

var EXPRESS_PORT = 4000;
var EXPRESS_ROOT = __dirname;
var LIVERELOAD_PORT = 35729;

// Let's make things more readable by
// encapsulating each part's setup
// in its own method
function startExpress() {

  var express = require('express');
  var app = express();
  app.use(require('connect-livereload')());
  app.use(express.static(EXPRESS_ROOT));
  app.listen(EXPRESS_PORT);
}

// We'll need a reference to the tinylr
// object to send notifications of file changes
// further down
var lr;
function startLivereload() {

  lr = require('tiny-lr')();
  lr.listen(LIVERELOAD_PORT);
}

// Notifies livereload of changes detected
// by `gulp.watch()` 
function notifyLivereload(event) {

  // `gulp.watch()` events provide an absolute path
  // so we need to make it relative to the server root
  var fileName = require('path').relative(EXPRESS_ROOT, event.path);

  lr.changed({
    body: {
      files: [fileName]
    }
  });
}

// Default task that will be run
// when no parameter is provided
// to gulp
gulp.task('default', function () {

  startExpress();
  startLivereload();
  gulp.watch('*.html', notifyLivereload);
});
var gulp = require('gulp');

// `gulp.task()` defines task that can be run calling `gulp xyz` from the command line
// The `default` task gets called when no task name is provided to Gulp
gulp.task('default', function () {
  
  console.log('Gulp and running!')
});
function startExpress() {

  var express = require('express');
  var app = express();
  app.use(require('connect-livereload')());
  app.use(express.static(__dirname));
  app.listen(4000);
}
// Don't forget to install `gulp-liverload` beforehand:
// `npm install gulp-livereload --save-dev`
function notifyLivereload(event) {

  gulp.src(event.path, {read: false})
      .pipe(require('gulp-livereload')(lr));
}
// https://github.com/sindresorhus/jshint-stylish example
gulp.task('default', function () {
    gulp.src(['file.js'])
        .pipe(jshint('.jshintrc'))
        .pipe(jshint.reporter('jshint-stylish'));
});
// ...

// We'll need a reference to the tinylr
// object to send notifications of file changes
var lr;
function startLivereload() {

  lr = require('tiny-lr')();
  lr.listen(35729);
}

// Default task that will be run
// when no parameter is provided
// to gulp
gulp.task('default', function () {

  startExpress();
  startLivereload();
});