Use NODE_ENV to test for test environment; improve scripts

This commit is contained in:
2025-06-16 22:41:29 -07:00
parent 014ae76634
commit ae91897ead
5 changed files with 19 additions and 20 deletions

30
server.cjs Normal file
View File

@@ -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}`);