-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
55 lines (49 loc) · 1.31 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
48
49
50
51
52
53
54
55
const del = require("del");
const gulp = require("gulp");
const browserify = require("browserify");
const tsify = require("tsify");
const source = require("vinyl-source-stream");
const buffer = require("vinyl-buffer");
const uglify = require("gulp-uglify");
const sourcemaps = require("gulp-sourcemaps");
const outputDirectory = "dist";
const sourceDirectory = "src";
gulp.task("clean", function () {
return del(`${outputDirectory}/**`, { force: true });
});
gulp.task("build:html", () => {
return gulp
.src([
"index.html",
`${sourceDirectory}/cascades/*`,
"opencv.js",
"utils.js",
])
.pipe(gulp.dest(outputDirectory));
});
gulp.task("build:js", () => {
return browserify({
basedir: ".",
debug: true,
entries: ["src/main.ts"],
standalone: "runApp",
cache: {},
packageCache: {},
})
.plugin(tsify)
.transform("babelify", {
presets: ["es2015"],
extensions: [".ts"],
})
.bundle()
.pipe(source("bundle.js"))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest(outputDirectory));
});
gulp.task("build", gulp.series(["build:html", "build:js"]));
gulp.task("watch", function () {
return gulp.watch(`${sourceDirectory}/**`, gulp.series(["build"]));
});