-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
47 lines (43 loc) · 1.28 KB
/
gulpfile.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var gulp = require('gulp');
var concat = require('gulp-concat');
var browserSync = require("browser-sync").create();
var sourcemaps = require('gulp-sourcemaps');
var pipeline = require('readable-stream').pipeline;
var terser = require('gulp-terser');
// concatenate all the files
gulp.task('concat', function() {
return pipeline(
gulp.src(['./js/*.js', './lib/*.js', '!lib/glpk.min.js', '!js/worker.js']),
sourcemaps.init(),
terser(),
concat('dist.js'),
sourcemaps.write(),
gulp.dest('./dist/')
)
});
// serve page from root folder, go directly to docs
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: "./",
// middleware: [{
// route: "/",
// // handle: (req, res, next) => {
// // res.writeHead(302, { 'Location': '/' })
// // res.end()
// // next()
// // }
// }]
}
});
});
// watch js and html files, reload when something changes
gulp.task('watch', function() {
gulp.watch(
['./js/*.js', './lib/*.js', './*.html'],
gulp.parallel('concat')
);
// browserSync.reload();
});
// default task
gulp.task('default', gulp.parallel('concat', 'serve', 'watch'));