generated from ESBuildTemplates/cross-lib.ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
41 lines (36 loc) · 935 Bytes
/
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
const gulp = require("gulp")
const tsc = require("gulp-typescript")
const esbuild = require("gulp-esbuild")
function bundleBrowser() {
return gulp
.src("src/index.ts")
.pipe(
esbuild({
tsconfig: "tsconfig.browser.json",
outfile: "bundle.js",
sourcemap: "external",
format: "iife",
minify: true,
bundle: true,
target: ["chrome58", "firefox57", "safari11", "edge16", "node14"],
globalName: "lib",
loader: {
".ts": "ts",
".json": "json",
},
})
)
.pipe(gulp.dest("dist/browser"))
}
function bundleNode() {
return gulp
.src("src/**/*.ts")
.pipe(tsc("tsconfig.node.json"))
.pipe(gulp.dest("dist/node"))
}
function watch() {
return gulp.watch("src/**/*.ts", bundle)
}
const bundle = gulp.parallel(bundleBrowser, bundleNode)
exports.bundle = bundle
exports.watch = gulp.series(bundle, watch)