-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (39 loc) · 1.37 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
const gulp = require('gulp');
const rimraf = require('rimraf');
const { series, watch, task, parallel } = gulp;
const browsersync = require('browser-sync');
const server = browsersync.create();
const shell = require('gulp-shell');
// Development server tasks
task("dev:serve", () => {
server.init({
files: [
"dist",
"assets"
],
watchEvents: ["add", "change", "addDir"],
server: ["assets", "dist"],
port: 8000,
browser: "google chrome"
})
});
// Typescript tasks
task('ts:watch', shell.task('npx rollup --config rollup.config.mjs --config-dev --watch'));
task('ts:type:compile', shell.task("npx tsc -d --allowJS --emitDeclarationOnly --declarationDir dist/temptypes"))
task('ts:type:clean', (cb) => {
rimraf('dist/temptypes', cb)
})
task('ts:compile', shell.task('npx rollup --config rollup.config.mjs'))
// Go tasks
task('go:clean', (cb) => {
rimraf('./src/api/lib.wasm', cb);
})
task('go:compile', shell.task('cd src/api/ && GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o lib.wasm $(find . -name "*.go" -type f -print0 | xargs -0)'))
task('go:watch', () => [
watch([
'src/api/**/*.go'
], series('go:compile'))
])
// Main tasks
task('dev', parallel(['go:watch', 'ts:watch', 'dev:serve']))
task('build', series(['go:clean', 'go:compile', 'ts:type:compile', 'ts:compile', 'ts:type:clean']))