mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-03-29 10:05:53 +00:00
79 lines
No EOL
2.2 KiB
JavaScript
79 lines
No EOL
2.2 KiB
JavaScript
const { execSync } = require('child_process');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const esbuild = require('esbuild');
|
|
const { prodOptions } = require('./esbuild-config.js');
|
|
|
|
async function build() {
|
|
console.log('Starting build process...');
|
|
|
|
// Ensure directories exist
|
|
console.log('Creating directories...');
|
|
execSync('node scripts/ensure-dirs.js', { stdio: 'inherit' });
|
|
|
|
// Copy assets
|
|
console.log('Copying assets...');
|
|
execSync('node scripts/copy-assets.js', { stdio: 'inherit' });
|
|
|
|
// Build CSS
|
|
console.log('Building CSS...');
|
|
execSync('npx tailwindcss -i ./src/client/styles.css -o ./public/bundle/styles.css --minify', { stdio: 'inherit' });
|
|
|
|
// Bundle client JavaScript
|
|
console.log('Bundling client JavaScript...');
|
|
|
|
try {
|
|
// Build main app bundle
|
|
await esbuild.build({
|
|
...prodOptions,
|
|
entryPoints: ['src/client/app-entry.ts'],
|
|
outfile: 'public/bundle/client-bundle.js',
|
|
});
|
|
|
|
// Build test bundle
|
|
await esbuild.build({
|
|
...prodOptions,
|
|
entryPoints: ['src/client/test-entry.ts'],
|
|
outfile: 'public/bundle/test.js',
|
|
});
|
|
|
|
// Build service worker
|
|
await esbuild.build({
|
|
...prodOptions,
|
|
entryPoints: ['src/client/sw.ts'],
|
|
outfile: 'public/sw.js',
|
|
format: 'iife', // Service workers need IIFE format
|
|
});
|
|
|
|
console.log('Client bundles built successfully');
|
|
} catch (error) {
|
|
console.error('Build failed:', error);
|
|
process.exit(1);
|
|
}
|
|
|
|
// Build server TypeScript
|
|
console.log('Building server...');
|
|
execSync('tsc', { stdio: 'inherit' });
|
|
|
|
// Build native executable
|
|
console.log('Building native executable...');
|
|
|
|
// Check for --custom-node flag
|
|
const useCustomNode = process.argv.includes('--custom-node');
|
|
|
|
if (useCustomNode) {
|
|
console.log('Using custom Node.js for smaller binary size...');
|
|
execSync('node build-native.js --custom-node', { stdio: 'inherit' });
|
|
} else {
|
|
console.log('Using system Node.js...');
|
|
execSync('node build-native.js', { stdio: 'inherit' });
|
|
}
|
|
|
|
console.log('Build completed successfully!');
|
|
}
|
|
|
|
// Run the build
|
|
build().catch(error => {
|
|
console.error('Build failed:', error);
|
|
process.exit(1);
|
|
}); |