mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
30 lines
846 B
TypeScript
30 lines
846 B
TypeScript
import { build } from 'esbuild'
|
|
import fs from 'node:fs'
|
|
import { latestDbVersion } from './src/detectLastDBVersion'
|
|
|
|
build({
|
|
entryPoints: ['src/index.ts'],
|
|
bundle: true,
|
|
target: 'node18.20.7',
|
|
platform: 'node',
|
|
packages: 'external',
|
|
outdir: './build',
|
|
sourcemap: true,
|
|
plugins: [
|
|
{
|
|
// hardcode last db version string into index.ts, before parsing
|
|
name: 'replace-latest-db-version-import',
|
|
setup(build) {
|
|
build.onLoad({ filter: /index\.ts$/ }, async (args) => {
|
|
let source = await fs.promises.readFile(args.path, 'utf8')
|
|
source = source.replace(
|
|
/import\s*\{\s*latestDbVersion\s*\}\s*from\s*['"][^'"]+['"]/,
|
|
`const latestDbVersion = "${latestDbVersion}";`,
|
|
)
|
|
return { contents: source, loader: 'ts' }
|
|
})
|
|
},
|
|
},
|
|
],
|
|
})
|