async function loadApp(configFile = undefined, args = {}) {
	/** @type {{ config: import("./app.js").App }}*/
	try {
		let appConfig = await loadFile(
			configFile
				? {
						configFile,
				  }
				: {
						name: "app",
				  },
		);

		if (appConfig.path) {
			if (!appConfig.export) {
				log(
					c.dim(
						c.green(
							`no vinxi app config found exported from ${basename(
								appConfig.path,
							)}`,
						),
					),
				);
				return undefined;
			}
			return appConfig.export;
		} else {
			const viteConfig = await loadFile({
				name: "vite",
			});

			// vinxi app config's have a "config" field
			if (viteConfig.path) {
				if (viteConfig.export.config) {
					log(
						c.dim(
							c.green(`found vinxi app config in ${basename(viteConfig.path)}`),
						),
					);
					return viteConfig.export;
				} else {
					log(c.dim(c.green("no vinxi app config found")));
					log(
						c.dim(c.green(`found vite config in ${basename(viteConfig.path)}`)),
					);

					const app = createApp({
						mode: args.mode,
						routers: [
							{
								name: "public",
								type: "static",
								dir: "./public",
							},
							{
								name: "client",
								type: "spa",
								handler: "./index.html",
								target: "browser",
								plugins: () => viteConfig.export.plugins ?? [],
							},
						],
					});

					return app;
				}
			}

			return undefined;
		}
	} catch (e) {
		console.error(e);

		return undefined;
	}
}
@param {string | undefined} configFile
@param {{ mode?: string }} args
@returns {Promise<import("./app.js").App | undefined>}