-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
44 lines (41 loc) · 885 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
42
43
44
const gulp = require("gulp");
const browserSync = require("browser-sync").create();
const esbuild = require("esbuild");
async function build() {
const time = Date.now();
await esbuild.build({
define: {
"process.env.NODE_ENV": '"development"',
},
bundle: true,
loader: {
".svg": "file",
},
outdir: "build",
entryPoints: ["src/index.tsx"],
platform: "browser",
});
console.log(`${Date.now() - time}ms`);
}
function serve() {
build();
browserSync.init({
server: {
baseDir: "build",
},
watchOptions: {
cwd: "build",
},
files: "*",
watch: false,
single: true,
ghostMode: false,
online: false,
minify: false,
localOnly: true,
ui: false,
});
gulp.watch("build/*").on("change", browserSync.reload);
gulp.watch("src/**").on("change", build);
}
exports.default = serve;