forked from SparkPost/heml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
63 lines (55 loc) · 1.32 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
"use strict";
import { deleteAsync } from "del";
import { obj } from "through2";
import babel from "gulp-babel";
import gulp from "gulp";
import path, { win32 } from "path";
const scripts = "./packages/*/src/**/*.js";
const builds = "./packages/*/build";
const dest = "packages";
let srcEx, libFragment;
if (win32 === path) {
srcEx = /(packages\\[^\\]+)\\src\\/;
libFragment = "$1\\build\\";
} else {
srcEx = new RegExp("(packages/[^/]+)/src/");
libFragment = "$1/build/";
}
export function build() {
return gulp
.src(scripts)
.pipe(
obj((file, enc, callback) => {
file._path = file.path;
file.path = file.path.replace(srcEx, libFragment);
callback(null, file);
}),
)
.pipe(
babel({
presets: [
["@babel/env", { targets: { node: 20 }, modules: false }],
["@babel/react"],
],
plugins: [
[
"@babel/plugin-transform-react-jsx",
{
runtime: "classic",
pragma: "utils.renderElement",
},
],
],
}),
)
.pipe(gulp.dest(dest))
.on("end", () => {
console.log(`Finished build`);
});
}
export function watch() {
gulp.watch(scripts, { debounceDelay: 200 }, build);
}
export function clean() {
return deleteAsync(builds);
}