-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.ts
80 lines (68 loc) · 1.78 KB
/
gulpfile.ts
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
73
74
75
76
77
78
79
80
import * as esbuild from 'esbuild';
import * as gulp from 'gulp';
import * as glob from 'glob';
import { syntaxGen } from './syntaxes/syntaxGen';
const defaultOption: esbuild.BuildOptions = {
platform: 'node',
format: 'cjs',
};
const serverDevOption: esbuild.BuildOptions = {
...defaultOption,
entryPoints: glob.sync('./server/src/**/*.ts'),
outdir: './server/out',
sourcemap: true
};
const clientDevOption: esbuild.BuildOptions = {
...defaultOption,
entryPoints: glob.sync('./client/src/**/*.ts'),
outdir: './client/out',
sourcemap: true
};
const serverOption: esbuild.BuildOptions = {
...defaultOption,
entryPoints: ['./server/src/server.ts'],
outdir: './server/out',
sourcesContent: false,
bundle: true,
external: ['vscode'],
minify: true,
treeShaking: true
};
const clientOption: esbuild.BuildOptions = {
...defaultOption,
entryPoints: ['./client/src/extension.ts'],
outfile: './client/out/extension.js',
bundle: true,
external: ['vscode'],
minify: true,
treeShaking: true
};
async function watchServer() {
const ctx = await esbuild.context(serverDevOption);
await ctx.watch();
}
async function watchClient() {
const ctx = await esbuild.context(clientDevOption);
await ctx.watch();
}
const buildServer = async () => await esbuild.build(serverOption);
const buildClient = async () => await esbuild.build(clientOption)
export const watch = gulp.parallel(watchServer, watchClient);
export const build = gulp.series(
buildServer,
buildClient,
);
gulp.task('buildAllWithMap', async (done) => {
try {
await esbuild.build(serverDevOption);
await esbuild.build(clientDevOption);
} catch (error) {
done(error);
return;
}
done();
});
gulp.task('syntax_gen', done => {
syntaxGen();
done();
})