/gulp-serve

Provide connect-server functionality

Primary LanguageJavaScriptMIT LicenseMIT

gulp-serve

Circle CI Downloads

Provide connect-server functionality, using connect.static

Install

Install with npm

npm i --save-dev gulp-serve

Usage

var gulp = require('gulp');
var serve = require('gulp-serve');

gulp.task('serve', serve('public'));
gulp.task('serve-build', serve(['public', 'build']));
gulp.task('serve-prod', serve({
  root: ['public', 'build'],
  port: 80,
  hostname: 'localhost',
  middleware: function(req, res) {
    // custom optional middleware
  }
}));

With HTTPS enabled (using built-in key and certificate for localhost):

var gulp = require('gulp');
var serve = require('gulp-serve');

gulp.task('serve', serve('public'));
gulp.task('serve-build', serve(['public', 'build']));
gulp.task('serve-prod', serve({
  root: ['public', 'build'],
  port: 443,
  https: true,
  middleware: function(req, res) {
    // custom optional middleware
  }
}));

With HTTPS enabled (using self provided key and certificate):

var gulp = require('gulp');
var serve = require('gulp-serve');

gulp.task('serve', serve('public'));
gulp.task('serve-build', serve(['public', 'build']));
gulp.task('serve-prod', serve({
  root: ['public', 'build'],
  port: 443,
  https: {
    key: 'path/to/cert.key',
    cert: 'path/to/cert.pem'
  },
  middleware: function(req, res) {
    // custom optional middleware
  }
}));

License

MIT