cryptgeon/packages/cli/scripts/build.js

35 lines
659 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
import { build, context } from 'esbuild'
import pkg from '../package.json' assert { type: 'json' }
2024-03-04 17:32:03 +00:00
const common = {
bundle: true,
minify: true,
platform: 'node',
define: { VERSION: `"${pkg.version}"` },
}
2024-03-04 17:32:03 +00:00
const cliOptions = {
...common,
entryPoints: ['./src/cli.ts'],
format: 'cjs',
outfile: './dist/cli.cjs',
}
const indexOptions = {
...common,
entryPoints: ['./src/index.ts'],
outfile: './dist/index.mjs',
format: 'esm',
}
const watch = process.argv.slice(2)[0] === '--watch'
if (watch) {
2024-03-04 17:32:03 +00:00
const ctx = await context(cliOptions)
ctx.watch()
} else {
2024-03-04 17:32:03 +00:00
await build(cliOptions)
await build(indexOptions)
}