aboutsummaryrefslogtreecommitdiffhomepage
path: root/apps/peertube-cli/scripts/build.js
blob: a9139acfae33e5a71dc098c7252b67743616d6ed (plain) (blame)
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
import * as esbuild from 'esbuild'
import { readFileSync } from 'fs'

const packageJSON = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)))

export const esbuildOptions = {
  entryPoints: [ './src/peertube.ts' ],
  bundle: true,
  platform: 'node',
  format: 'esm',
  target: 'node16',
  external: [
    './lib-cov/fluent-ffmpeg',
    'pg-hstore'
  ],
  outfile: './dist/peertube.js',
  banner: {
    js: `const require = (await import("node:module")).createRequire(import.meta.url);` +
      `const __filename = (await import("node:url")).fileURLToPath(import.meta.url);` +
      `const __dirname = (await import("node:path")).dirname(__filename);`
  },
  define: {
    'process.env.PACKAGE_VERSION': `'${packageJSON.version}'`
  }
}

await esbuild.build(esbuildOptions)