-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathesbuild.ts
More file actions
47 lines (41 loc) · 1.09 KB
/
Copy pathesbuild.ts
File metadata and controls
47 lines (41 loc) · 1.09 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
47
/* eslint-disable no-console */
import { context } from 'esbuild'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
const watch = process.argv.includes('--watch')
//@ts-ignore
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const getPath = (file: string) => resolve(__dirname, file)
const formats = ['esm', 'cjs'] as const
const contexts = await Promise.all(
formats.flatMap((format) =>
[false, true].map((minify) =>
context({
entryPoints: ['./src/index.mts'],
bundle: true,
outfile: getPath(`../../solid/index${minify ? '.min' : ''}.${format === 'esm' ? 'm' : 'c'}js`),
external: ['solid-js'],
platform: 'browser',
format,
sourcemap: watch,
minify,
tsconfig: './tsconfig.json',
}),
),
),
)
for (const ctx of contexts) {
if (watch) {
await ctx.watch()
console.info('👀 watching for changes...')
process.on('exit', async () => {
console.info('🙈 process killed')
await ctx.dispose()
})
} else {
await ctx.rebuild()
console.info('✅ build complete')
await ctx.dispose()
}
}