Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
gulp-webserver-fast
Advanced tools
Gulp plugin to run a local webserver with LiveReload
Streaming gulp plugin to run a local webserver with LiveReload
$ npm install --save-dev gulp-webserver
The gulp.src('root')
parameter is the root directory of the webserver. Multiple directories are possible.
var gulp = require('gulp');
var webserver = require('gulp-webserver');
gulp.task('webserver', function() {
gulp.src('app')
.pipe(webserver({
livereload: true,
directoryListing: true,
open: true
}));
});
Key | Type | Default | Description |
---|---|---|---|
host | String | localhost | hostname of the webserver |
port | Number | 8000 | port of the webserver |
path | String | / | path to the webserver |
livereload | Boolean/Object | false | whether to use livereload. For advanced options, provide an object. You can use the 'port' property to set a custom live reload port and the filter function to filter out files to watch. The object also needs to set enable property to true (e.g. enable: true ) in order to activate the livereload mode. It is off by default. |
directoryListing | Boolean/Object | false | whether to display a directory listing. For advanced options, provide an object with the 'enable' property set to true. You can use the 'path' property to set a custom path or the 'options' property to set custom serve-index options. |
fallback | String | undefined | file to fall back to (relative to webserver root) |
open | Boolean/String | false | open the localhost server in the browser. By providing a String you can specify the path to open (for complete path, use the complete url http://my-server:8080/public/ ) . |
https | Boolean/Object | false | whether to use https or not. By default, gulp-webserver provides you with a development certificate but you remain free to specify a path for your key and certificate by providing an object like this one: {key: 'path/to/key.pem', cert: 'path/to/cert.pem'} . |
middleware | Function/Array | [] | a connect middleware function or a list of middleware functions |
proxies | Array | [] | a list of proxy objects. Each proxy object can be specified by {source: '/abc', target: 'http://localhost:8080/abc', options: {headers: {'ABC_HEADER': 'abc'}}} . |
Solution: Set 0.0.0.0
as host
option.
html5Mode
for my single page app with this plugin?Solution: Set the index.html
of your application as fallback
option. For example:
gulp.task('webserver', function() {
gulp.src('app')
.pipe(webserver({
fallback: 'index.html'
}));
});
Solution: Set enable: true
and provide filter function in filter:
property of the livereload object. For example:
gulp.task('webserver', function() {
gulp.src('app')
.pipe(webserver({
livereload: {
enable: true, // need this set to true to enable livereload
filter: function(fileName) {
if (fileName.match(/.map$/)) { // exclude all source maps from livereload
return false;
} else {
return true;
}
}
}
}));
});
Solution: Either by pressing Ctrl + C
or programmatically like in this example:
var stream = gulp.src('app').pipe(webserver());
stream.emit('kill');
FAQs
Gulp plugin to run a local webserver with LiveReload
The npm package gulp-webserver-fast receives a total of 0 weekly downloads. As such, gulp-webserver-fast popularity was classified as not popular.
We found that gulp-webserver-fast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.