summaryrefslogtreecommitdiff
path: root/tools/vscode/scripts/build.mjs
blob: baaaa207f9771b405ff80c8aec800c87c4b9bd16 (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
28
29
30
31
32
33
34
35
36
37
import esbuild from 'esbuild';
import config from './esbuild.config.mjs';
import { performance } from 'perf_hooks';

function buildClient() {
  return esbuild.build({
    ...config,
    entryPoints: ['packages/client/src/index.ts'],
    outfile: 'dist/index.js',
  });
}

function buildServer() {
  return esbuild.build({
    ...config,
    entryPoints: ['packages/server/src/index.ts'],
    outfile: 'dist/server.js',
  });
}

async function build() {
  const start = performance.now();
  try {
    await Promise.all([buildClient(), buildServer()]);
  } catch ({ errors }) {
    if (errors[0].text.indexOf('Could not resolve') > -1) {
      console.error('Make sure you run "npm run bootstrap" first!');
    }
    return;
  }
  const end = performance.now();
  const span = end - start;

  console.log(`✨ Built in ${Math.round(span)}ms!`);
}

build();