cb9d836227
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
23 lines
771 B
JavaScript
23 lines
771 B
JavaScript
import { preview } from 'vite';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { positiveInteger } from './playwright-runtime.mjs';
|
|
import { verifyBuild } from './verify-build.mjs';
|
|
|
|
const directory =
|
|
process.env.PW_DIST_DIR ||
|
|
fileURLToPath(new URL('../dist/', import.meta.url));
|
|
const portIndex = process.argv.indexOf('--port');
|
|
const port = positiveInteger(
|
|
portIndex === -1 ? 4176 : process.argv[portIndex + 1],
|
|
'port',
|
|
);
|
|
if (port > 65535) throw new Error('port must be <= 65535');
|
|
await verifyBuild(directory);
|
|
const server = await preview({
|
|
build: { outDir: directory },
|
|
preview: { host: '127.0.0.1', port, strictPort: true },
|
|
});
|
|
server.printUrls();
|
|
for (const signal of ['SIGTERM', 'SIGINT'])
|
|
process.on(signal, () => server.httpServer.close());
|