Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
blob: 47e47232d7d5ed856c98ba86c0afb41d418eefe7 (plain)
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
const { createServer } = require('esbuild-server');

const server = createServer(
  {
    bundle: true,
    define: {
      'env': `"${process.env.NODE_ENV || 'dev'}"`,
    },
    entryPoints: ['src/index.js', 'src/map.js', 'src/soldier_record_block.js'],
    ...(process.env.NODE_ENV !== 'test') && {
      outdir: 'build'
    }
  },
  {
    static: 'public',
    ...(process.env.NODE_ENV === 'test') && {
      port: 3005,
      injectLiveReload: false,
      watch: false
    }
  }
);

const buildStart = Date.now();
server
  .start()
  .then(() => {
    console.log(`Build completed in ${Date.now() - buildStart}ms`);
  })
  .catch(() => {
    console.error('Build failed');
  });
console.log(`${process.env.NODE_ENV === 'test' ? 'Test' : 'Development'} server running at ${server.url}`);