first draft
This commit is contained in:
20
scripts/serve-dist.mjs
Normal file
20
scripts/serve-dist.mjs
Normal file
@@ -0,0 +1,20 @@
|
||||
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));
|
||||
Reference in New Issue
Block a user