mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-22 15:36:57 +00:00
42 lines
902 B
TypeScript
42 lines
902 B
TypeScript
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()
|
|
})()
|