-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.js
45 lines (41 loc) · 1.11 KB
/
build.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
import windiCssPlugin from '@luncheon/esbuild-plugin-windicss'
import esbuild from 'esbuild'
import babel from 'esbuild-plugin-babel'
import pipe from 'esbuild-plugin-pipe'
import fs from 'node:fs'
fs.mkdirSync('docs', { recursive: true })
fs.copyFileSync('src/index.html', 'docs/index.html')
fs.copyFileSync('src/favicon.png', 'docs/favicon.png')
fs.copyFileSync('src/manifest.webmanifest', 'docs/manifest.webmanifest')
const windiCss = windiCssPlugin({ filter: /^$/, windiCssConfig: { prefixer: false } })
/**
* @satisfies esbuild.BuildOptions
*/
const options = {
entryPoints: ['src/index.tsx'],
outdir: 'docs',
bundle: true,
minify: true,
format: 'esm',
logLevel: 'info',
plugins: [
pipe({
filter: /\.tsx$/,
plugins: [
windiCss,
babel({
config: { presets: ['@babel/preset-typescript', 'babel-preset-solid'] },
}),
],
}),
windiCss,
],
}
if (process.argv.includes('--serve')) {
esbuild
.context(options)
.then(ctx => ctx.serve({ servedir: options.outdir }))
.then(console.log('http://localhost:8000'))
} else {
esbuild.build(options)
}