feat: fix build scripts and server

This commit is contained in:
Aarnav Tale
2025-01-01 15:06:22 +05:30
parent f3c9d8b54c
commit a4bb3cce5f
7 changed files with 605 additions and 929 deletions
+33
View File
@@ -0,0 +1,33 @@
import { defineConfig } from 'vite';
const prefix = process.env.__INTERNAL_PREFIX || '/admin';
if (prefix.endsWith('/')) {
throw new Error('Prefix must not end with a slash');
}
export default defineConfig(() => {
return {
build: {
minify: false,
target: 'esnext',
rollupOptions: {
input: './server/prod.mjs',
output: {
entryFileNames: 'server.js',
dir: 'build/headplane',
banner: '#!/usr/bin/env node\n',
},
external: (id) => id.startsWith('node:') || id === 'ws',
},
},
define: {
PREFIX: JSON.stringify(prefix),
},
resolve: {
alias: {
stream: 'node:stream',
crypto: 'node:crypto',
},
},
};
});