chronocat/scripts/build.cts

42 lines
902 B
TypeScript
Raw Normal View History

2024-03-03 16:15:52 +00:00
import { analyzeMetafile, context } from 'esbuild'
import { join } from 'node:path'
import { cwd } from 'node:process'
const wd = cwd()
void (async () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const { version } = require(join(wd, 'package.json'))
const ctx = await context({
entryPoints: [join(wd, 'src/index.ts')],
write: true,
outdir: 'lib',
loader: {
'.yml': 'text',
'.html': 'text',
'.txt': 'text',
},
platform: 'node',
format: 'cjs',
tsconfig: join(wd, 'tsconfig.json'),
define: {
__DEFINE_CHRONO_VERSION__: `'${version}'`,
},
external: ['electron'],
bundle: true,
minify: true,
sourcemap: false,
metafile: true,
color: true,
})
console.log(await analyzeMetafile((await ctx.rebuild()).metafile))
await ctx.dispose()
})()