-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathesbuild.mjs
More file actions
46 lines (39 loc) · 1.17 KB
/
esbuild.mjs
File metadata and controls
46 lines (39 loc) · 1.17 KB
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
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { build, context } from 'esbuild'
const watch = process.argv.includes('--watch')
const root = path.dirname(fileURLToPath(import.meta.url))
const shared = {
absWorkingDir: root,
bundle: true,
format: 'cjs',
platform: 'node',
sourcemap: true,
sourcesContent: false,
target: 'node20',
tsconfig: path.join(root, 'tsconfig.json')
}
const extensionBuild = {
...shared,
entryPoints: ['src/extension.ts'],
external: ['vscode'],
outfile: 'dist/extension.js'
}
const workerBuild = {
...shared,
entryPoints: ['src/render/mathjax/mathjax.worker.ts'],
outfile: 'dist/render/mathjax/mathjax.worker.js'
}
async function main() {
if (watch) {
const [extensionCtx, workerCtx] = await Promise.all([context(extensionBuild), context(workerBuild)])
await Promise.all([extensionCtx.watch(), workerCtx.watch()])
console.log('Watching esbuild bundles for latex-math-preview...')
return
}
await Promise.all([build(extensionBuild), build(workerBuild)])
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})