-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
33 lines (31 loc) · 757 Bytes
/
gulpfile.js
File metadata and controls
33 lines (31 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var gulp = require('gulp');
var webserver = require('gulp-webserver');
gulp.task('default', function() {
gulp.src('dummy-html')
.pipe(webserver({
port: 8001,
directoryListing: false,
open: true,
middleware: function (req, res, next) {
console.log(req.url);
next();
}
}));
});
gulp.task('redirect', function() {
gulp.src('dummy-html')
.pipe(webserver({
port: 8001,
directoryListing: false,
open: true,
middleware: function (req, res, next) {
console.log(req.url);
if (req.url.startsWith('/third.html')) {
res.writeHead(301, {'Location': '/another.html'});
res.end()
} else {
next();
}
}
}));
});