UNPKG

@equinor/fusion-framework-cli

Version:

--- title: Fusion Framework CLI ---

54 lines 2.71 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { AssertionError } from 'node:assert'; import { Spinner } from './spinner.js'; import { formatPath, chalk } from './format.js'; import { createAppViteConfig, createViteConfig } from '../../lib/vite-config.js'; import { mergeConfig } from 'vite'; export const loadViteConfig = (env, options) => __awaiter(void 0, void 0, void 0, function* () { const spinner = Spinner.Current; try { spinner.start('load local vite configuration'); const appViteConfig = yield createAppViteConfig(env, { file: options === null || options === void 0 ? void 0 : options.file, }); spinner.succeed(); if (appViteConfig === null || appViteConfig === void 0 ? void 0 : appViteConfig.path) { spinner.info(`🛠️ ${formatPath(appViteConfig.path, { relative: true })}`); } else if (options === null || options === void 0 ? void 0 : options.file) { spinner.fail(`failed to load vite config from ${formatPath(options === null || options === void 0 ? void 0 : options.file)}`); throw new AssertionError({ message: `Expected to load config from ${formatPath(options === null || options === void 0 ? void 0 : options.file)}`, expected: '<UserConfig>', }); } else { spinner.info(chalk.dim(`no local vite config applied, using built-in see ${formatPath('https://vitejs.dev/config/')}`)); } spinner.start('create vite configuration'); const viteConfig = yield createViteConfig(env); spinner.succeed(); if (appViteConfig === null || appViteConfig === void 0 ? void 0 : appViteConfig.config) { return { viteConfig: mergeConfig(viteConfig, appViteConfig.config), path: appViteConfig.path, }; } else { return { viteConfig }; } } catch (err) { spinner.fail(); throw err; } }); //# sourceMappingURL=load-vite-config.js.map