-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
72 lines (62 loc) · 2.49 KB
/
gulpfile.js
File metadata and controls
72 lines (62 loc) · 2.49 KB
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
71
72
const gulp = require("gulp");
const path = require("path");
const pretty = require("gulp-prettier");
const prettier_config = require("./prettier.config.js");
const ts = require("gulp-typescript");
const uglify = require("gulp-uglify");
const rename = require("gulp-rename");
const browserify = require("gulp-browserify");
const clean = require("gulp-clean-old");
const cache_path = path.join(__dirname, "cache");
const output_path = path.join(__dirname, "dist");
const resource_path = path.join(__dirname, "src/main/resource");
const typescript_src = path.join(__dirname, "src/**/*.ts");
const format_script_dist = path.join(__dirname, "src");
const build_src_html = path.join(__dirname, "cache/main/index.js");
const build_dist_html = path.join(__dirname, "dist");
const copy_src_html = path.join(__dirname, "src/main/index.html");
const copy_dist_html = build_dist_html;
const copy_src_resource = path.join(resource_path, "**/*");
const copy_dist_resource = path.join(output_path, "resource");
const copy_src_ico = path.join(__dirname, "src/main/favicon.ico");
const copy_dist_ico = build_dist_html;
gulp.task("format", function () {
return gulp.src(typescript_src).pipe(pretty(prettier_config)).pipe(gulp.dest(format_script_dist));
});
gulp.task("copy_html", function () {
return gulp.src(copy_src_html, {}).pipe(gulp.dest(copy_dist_html));
});
gulp.task("copy_resource", function () {
return gulp.src(copy_src_resource, {}).pipe(gulp.dest(copy_dist_resource));
});
gulp.task("copy_ico", function () {
return gulp.src(copy_src_ico, {}).pipe(gulp.dest(copy_dist_ico));
});
gulp.task("copy", gulp.parallel("copy_html", "copy_resource", "copy_ico"));
gulp.task("clean_cache", function () {
return gulp.src(cache_path + "/*", { read: false }).pipe(clean());
});
gulp.task("clean_dist", function () {
return gulp.src(output_path + "/*", { read: false }).pipe(clean());
});
gulp.task("clean", gulp.parallel("clean_cache", "clean_dist"));
gulp.task("cmd_complied", function () {
return gulp
.src(typescript_src)
.pipe(ts({ noImplicitAny: true, module: "commonjs" }))
.pipe(gulp.dest(cache_path));
});
gulp.task("cmd_link_html", function () {
return gulp
.src(build_src_html)
.pipe(browserify({ insertGlobals: false }))
.pipe(gulp.dest(build_dist_html))
.pipe(uglify())
.pipe(rename({ extname: ".min.js" }))
.pipe(gulp.dest(build_dist_html));
});
gulp.task(
"build",
gulp.series("clean", gulp.parallel("copy", gulp.series("cmd_complied", gulp.parallel("cmd_link_html"))))
);
// TODO: gulp start -- watch 热更新