gulp-connect

WebJar for gulp-connect

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

gulp-connect
Last Version

Last Version

2.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

gulp-connect
WebJar for gulp-connect
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/avevlad/gulp-connect

Download gulp-connect

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/gulp-connect/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>gulp-connect</artifactId>
    <version>2.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/gulp-connect/
implementation 'org.webjars.npm:gulp-connect:2.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/gulp-connect/
implementation ("org.webjars.npm:gulp-connect:2.2.0")
'org.webjars.npm:gulp-connect:jar:2.2.0'
<dependency org="org.webjars.npm" name="gulp-connect" rev="2.2.0">
  <artifact name="gulp-connect" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='gulp-connect', version='2.2.0')
)
libraryDependencies += "org.webjars.npm" % "gulp-connect" % "2.2.0"
[org.webjars.npm/gulp-connect "2.2.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.webjars.npm : connect jar (,2.18.0)
org.webjars.npm : event-stream jar [3.1.0,3.2)
org.webjars.npm : tiny-lr jar [0.0.7,0.0.8)
org.webjars.npm : gulp-util jar [2.2.14,2.3)
org.webjars.npm : connect-livereload jar [0.3.2,0.4)

Project Modules

There are no modules declared in this project.

gulp-connect Build Status Join the chat at https://gitter.im/AveVlad/gulp-connect

Gulp plugin to run a webserver (with LiveReload)

Sponsors

gulp-connect is sponsored by JetBrains!

Install

npm install --save-dev gulp-connect

Usage

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

gulp.task('connect', function() {
  connect.server();
});

gulp.task('default', ['connect']);

LiveReload

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

gulp.task('connect', function() {
  connect.server({
    root: 'app',
    livereload: true
  });
});

gulp.task('html', function () {
  gulp.src('./app/*.html')
    .pipe(gulp.dest('./app'))
    .pipe(connect.reload());
});

gulp.task('watch', function () {
  gulp.watch(['./app/*.html'], ['html']);
});

gulp.task('default', ['connect', 'watch']);

Start and stop server

gulp.task('jenkins-tests', function() {
  connect.server({
    port: 8888
  });
  // run some headless tests with phantomjs
  // when process exits:
  connect.serverClose();
});

Multiple server

var gulp = require('gulp');
var connect = require('gulp-connect');
var stylus = require('gulp-stylus');

gulp.task('connectDev', function () {
  connect.server({
    name: 'Dev App',
    root: ['app', 'tmp'],
    port: 8000,
    livereload: true
  });
});

gulp.task('connectDist', function () {
  connect.server({
    name: 'Dist App',
    root: 'dist',
    port: 8001,
    livereload: true
  });
});

gulp.task('html', function () {
  gulp.src('./app/*.html')
    .pipe(gulp.dest('./app'))
    .pipe(connect.reload());
});

gulp.task('stylus', function () {
  gulp.src('./app/stylus/*.styl')
    .pipe(stylus())
    .pipe(gulp.dest('./app/css'))
    .pipe(connect.reload());
});

gulp.task('watch', function () {
  gulp.watch(['./app/*.html'], ['html']);
  gulp.watch(['./app/stylus/*.styl'], ['stylus']);
});

gulp.task('default', ['connectDist', 'connectDev', 'watch']);

http2 support

If the http2 package is installed and you use an https connection to gulp connect then http 2 will be used in preference to http 1.

API

options.root

Type: Array or String Default: Directory with gulpfile

The root path

options.port

Type: Number Default: 8080

The connect webserver port

options.host

Type: String Default: localhost

options.name

Type: String Default: Server

The name that will be output when the server starts/stops.

options.https

Type: Object Default: false

Can be any options documented at https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener

When https is just set to true (boolean), then internally some defaults will be used.

options.livereload

Type: Object or Boolean Default: false

options.livereload.port

Type: Number Default: 35729

Overrides the hostname of the script livereload injects in index.html

options.livereload.hostname

Type: String Default: 'undefined'

options.fallback

Type: String Default: undefined

Fallback file (e.g. index.html)

options.middleware

Type: Function Default: []

options.debug

Type: Boolean Default: false

options.index

Type: Boolean or String of a new index pass or Array of new indexes in preferred order Default: true

gulp.task('connect', function() {
  connect.server({
    root: "app",
    middleware: function(connect, opt) {
      return [
        // ...
      ]
    }
  });
});

Contributing

To contribute to this project, you must have CoffeeScript installed: npm install -g coffee-script.

Then, to build the index.js file, run coffee -o . -bc src/. Run npm test to run the tests.

Contributors

Versions

Version
2.2.0