From d2c218f72d1ad5bd65407433a51688b0a9bd0d89 Mon Sep 17 00:00:00 2001
From: Catalin Mititiuc
Date: Thu, 2 May 2024 09:40:05 -0700
Subject: Use NODE_ENV to test for test environment; improve scripts
---
server.cjs | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 server.cjs
(limited to 'server.cjs')
diff --git a/server.cjs b/server.cjs
new file mode 100644
index 0000000..b5bd00f
--- /dev/null
+++ b/server.cjs
@@ -0,0 +1,30 @@
+const { createServer } = require('esbuild-server');
+
+const server = createServer(
+ {
+ bundle: true,
+ entryPoints: ['src/index.js', 'src/map.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}`);
--
cgit v1.2.3