feat: add naive app

This commit is contained in:
vben
2024-07-31 00:19:17 +08:00
parent 832a7bcc58
commit fdee2d2239
68 changed files with 2540 additions and 33 deletions

View File

@@ -32,6 +32,7 @@
"cheerio": "1.0.0-rc.12",
"html-minifier-terser": "^7.2.0",
"nitropack": "^2.9.7",
"portfinder": "^1.0.32",
"resolve.exports": "^2.0.2",
"vite-plugin-lib-inject-css": "^2.1.1",
"vite-plugin-pwa": "^0.20.1",

View File

@@ -5,6 +5,7 @@ import type { NitroMockPluginOptions } from '../typing';
import { colors, consola, getPackage } from '@vben/node-utils';
import { build, createDevServer, createNitro, prepare } from 'nitropack';
import portfinder from 'portfinder';
const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
@@ -75,7 +76,13 @@ async function runNitroServer(rootDir: string, port: number, verbose: boolean) {
},
);
nitro.hooks.hookOnce('restart', reload);
const server = createDevServer(nitro);
// 端口已经存在
const availablePort = await portfinder.getPortPromise({ port });
if (availablePort !== port) {
return;
}
await server.listen(port, { showURL: false });
await prepare(nitro);
await build(nitro);