Gulp plugin to run a webserver (with LiveReload)
npm install --save-dev gulp-connect
var gulp = require('gulp'),
connect = require('gulp-connect');
gulp.task('connect', function() {
connect.server();
});
gulp.task('default', ['connect']);
var gulp = require('gulp'),
connect = require('gulp-connect');
gulp.task('connect', function() {
connect.server({
root: 'app',
livereload: true
});
});
gulp.task('html', function () {
gulp.src('./app/*.html')
.pipe(connect.reload());
});
gulp.task('watch', function () {
gulp.watch(['./app/*.html'], ['html']);
});
gulp.task('default', ['connect', 'watch']);
gulp.task('jenkins-tests', function() {
connect.server({
port: 8888
});
// run some headless tests with phantomjs
// when process exits:
connect.serverClose();
});
var gulp = require('gulp'),
stylus = require('gulp-stylus'),
connect = require('gulp-connect');
gulp.task('connectDev', function () {
connect.server({
root: ['app', 'tmp'],
port: 8000,
livereload: true
});
});
gulp.task('connectDist', function () {
connect.server({
root: 'dist',
port: 8001,
livereload: true
});
});
gulp.task('html', function () {
gulp.src('./app/*.html')
.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']);
Type: Array or String
Default: Directory with gulpfile
The root path
Type: Number
Default: 8080
The connect webserver port
Type: String
Default: localhost
Type: Boolean
Default: false
Type: Object or Boolean
Default: false
Type: Number
Default: 35729
Type: String
Default: undefined
Fallback file (e.g. index.html
)
Type: Function
Default: []
gulp.task('connect', function() {
connect.server({
root: "app",
middleware: function(connect, opt) {
return [
// ...
]
}
});
});
AveVlad and schickling