92380ebab6
验证:713 项单测、8 视口环境、代码及格式检查通过;未运行生产构建。
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
/*
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
*/
|
|
|
|
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());
|