one
Version:
One is a new React Framework that makes Vite serve both native and web.
41 lines (40 loc) • 1.15 kB
JavaScript
import { loadConfigFromFile } from "vite";
function setOneOptions(next) {
globalThis.__oneOptions = next;
}
function getUserOneOptions() {
if (!globalThis.__oneOptions) {
throw new Error(`One not loaded properly, is the one() plugin in your vite.config.ts?`);
}
return globalThis.__oneOptions;
}
async function loadUserOneOptions(command) {
var silent = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
var originalConsoleError = console.error;
if (silent) {
console.error = function () {};
}
try {
var config = await loadConfigFromFile({
mode: command === "serve" ? "dev" : "prod",
command
});
if (!config) {
throw new Error(`No config config in ${process.cwd()}. Is this the correct directory?`);
}
var oneOptions = getUserOneOptions();
if (!oneOptions) {
throw new Error(`No One plugin config in this vite.config`);
}
return {
config,
oneOptions
};
} finally {
if (silent) {
console.error = originalConsoleError;
}
}
}
export { loadUserOneOptions, setOneOptions };
//# sourceMappingURL=loadConfig.native.js.map