vite-plugin-zephyr
Version:
Vite plugin for Zephyr
31 lines (30 loc) • 1.51 kB
JavaScript
import { ze_log } from "zephyr-agent";
import { normalizeEntrypoint } from "../utils/normalize-entrypoint.mjs";
function extractEntrypoint(config) {
const input = config.build?.rollupOptions?.input;
if (input) {
if ('string' == typeof input) {
ze_log.init(`Detected entrypoint from Vite config: ${input}`);
return normalizeEntrypoint(input);
}
if ('object' == typeof input && !Array.isArray(input)) {
const entries = Object.entries(input);
if (entries.length > 0) {
const [firstKey, firstValue] = entries[0];
if (entries.length > 1) ze_log.init(`Multiple entrypoints detected (${entries.length}). Using first: ${firstKey} -> ${firstValue}`);
else ze_log.init(`Detected entrypoint from Vite config: ${firstKey} -> ${firstValue}`);
return normalizeEntrypoint(String(firstValue));
}
}
if (Array.isArray(input) && input.length > 0) {
const firstEntry = input[0];
if (input.length > 1) ze_log.init(`Multiple entrypoints detected (${input.length}). Using first: ${firstEntry}`);
else ze_log.init(`Detected entrypoint from Vite config: ${firstEntry}`);
return normalizeEntrypoint(String(firstEntry));
}
}
ze_log.init('No entrypoint specified, using Vite default: index.html');
return 'index.html';
}
export { extractEntrypoint };
//# sourceMappingURL=extract-entrypoint.mjs.map