Gulp Live Server

0.0.31 · abandoned · verified Sun Apr 19

gulp-live-server is a lightweight Gulp plugin designed to provide a development server with integrated live-reloading capabilities for static assets or Node.js applications. It abstracts the complexities of setting up a web server (potentially using `connect` or `express` internally) and a separate LiveReload server (via `tiny-lr`), allowing developers to quickly spin up a server and have their browser automatically refresh upon file changes. The package offers methods for serving static files, running a custom Node.js script as the server, and notifying the browser of updates. Despite its utility, the package is largely unmaintained, with its last release (version 0.0.31) dating back over 7 years to July 2017. Users should be aware of potential compatibility issues with newer Node.js versions or modern Gulp setups, especially those using ES Modules.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `gulp-live-server` to serve static files from one or multiple directories and configure live-reloading upon file changes.

const gulp = require('gulp');
const gls = require('gulp-live-server');

gulp.task('serve-static', function() {
  // 1. Serve with default settings (serves 'public' folder on port 3000)
  const server = gls.static();
  server.start();

  // 2. Serve at a custom port for 'dist' folder
  const customPortServer = gls.static('dist', 8888);
  customPortServer.start();

  // 3. Serve multiple folders
  const multiFolderServer = gls.static(['dist', '.tmp']);
  multiFolderServer.start();

  // Use gulp.watch to trigger server actions (notify, start or stop)
  gulp.watch(['static/**/*.css', 'static/**/*.html'], function (file) {
    server.notify.apply(server, [file]);
    customPortServer.notify.apply(customPortServer, [file]);
    multiFolderServer.notify.apply(multiFolderServer, [file]);
  });
});

// To run: `gulp serve-static`

view raw JSON →