20 lines
815 B
JavaScript
20 lines
815 B
JavaScript
import { spawn } from 'node:child_process';
|
|
import { dirname, join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(__dirname, '..');
|
|
const port = process.env.PORT ?? '3223';
|
|
|
|
// Serve from project root so root `serve.json` applies (no-store for *.js).
|
|
// Passing the dist path as the CLI directory makes `serve` look for serve.json
|
|
// inside dist, which is wiped on build — and default caching can leave a stale
|
|
// main.js pointing at old hashed chunk names after `yarn dev` rebuilds.
|
|
const serveBin = join(root, 'node_modules', '.bin', 'serve');
|
|
const child = spawn(serveBin, ['-l', port, '--cors', '--no-etag'], {
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
cwd: root,
|
|
});
|
|
|
|
child.on('exit', (code) => process.exit(code ?? 0)); |