-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (55 loc) · 1.81 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const gulp = require("gulp"),
mocha = require("gulp-mocha"),
ts = require("gulp-typescript"),
tsProject = ts.createProject("tsconfig.json"),
fsExtra = require("fs-extra"),
runSequence = require("run-sequence"),
path = require("path"),
webpack = require("webpack"),
exec = require("child_process").exec;
let glue = suffix => gulp.src(`src/**/*.${suffix}`).pipe(gulp.dest("lib"));
let watch = (suffix, tasks) => {
tasks = tasks ? tasks : [suffix];
return gulp.watch(`src/**/*.${suffix}`, tasks);
};
gulp.task("pug", () => glue("pug"));
gulp.task("ts", () => {
let tsResult = tsProject.src().pipe(tsProject());
return tsResult.js.pipe(gulp.dest("lib"));
});
gulp.task("watch-ts", () => watch("ts"));
gulp.task("watch-pug", () => watch("pug"));
gulp.task("unit", ["build"], () => {
return gulp
.src("test/unit/**/*.js", { read: false })
.pipe(mocha({ require: ["babel-register"] }));
});
gulp.task("it", ["build"], () => {
return gulp
.src("test/it/**/*-test.js", { read: false })
.pipe(mocha({ require: ["babel-register"] }));
});
gulp.task("clean", done => {
fsExtra.remove("lib", done);
});
gulp.task("client", done => {
let cfg = require("./src/client/webpack.config");
cfg.output.path = path.resolve("./lib/client/public");
webpack(cfg, done);
});
gulp.task("install-client-dependencies", done => {
exec("cd src/client && npm install && cd ..", done);
});
gulp.task("polyfills", () => {
gulp
.src(["src/client/node_modules/@webcomponents/**/*"])
.pipe(gulp.dest("lib/client/node_modules/@webcomponents"));
});
gulp.task("build", done =>
runSequence("clean", ["pug", "ts", "client", "polyfills"], done)
);
gulp.task("dev", ["build", "watch-pug", "watch-ts"]);
gulp.task("test", ["unit"]);
gulp.task("postinstall", done =>
runSequence("install-client-dependencies", done)
);