-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
57 lines (50 loc) · 1.53 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
const gulp = require("gulp");
const ts = require("gulp-typescript");
const browserify = require("browserify");
const source = require("vinyl-source-stream");
const buffer = require('vinyl-buffer');
const tsify = require("tsify");
const uglify = require('gulp-uglify');
const tsProject = ts.createProject("tsconfig.json");
/**
* Build lib for publishing to npm
*/
gulp.task("build-lib", function() {
return tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest("build"));
});
/**
* Build dist files for direct web import
*/
gulp.task("build-dist", function() {
return browserify({ basedir: ".", entries: ["src/lib/web.ts"], })
.plugin(tsify, { project: "tsconfig.json" })
.bundle()
.pipe(source('poweraudio.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest("dist"));
});
/**
* Build public docs
*/
gulp.task("build-docs-ts", function() {
return browserify({ basedir: ".", entries: ["src/docs/index.ts"], })
.plugin(tsify, { project: "tsconfig.docs.json" })
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest("docs"));
});
gulp.task("build-docs-assets", function() {
return gulp.src(["src/docs/*.{html,mp3,css}", "src/docs/CNAME"]).pipe(gulp.dest('docs'));
});
gulp.task("build-docs", gulp.series('build-docs-assets', 'build-docs-ts'));
/**
* Build all
*/
gulp.task('build', gulp.parallel('build-lib', 'build-dist', 'build-docs'));
// Default
gulp.task('default', gulp.parallel('build'));