|
- "use strict";
- var __create = Object.create;
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __getProtoOf = Object.getPrototypeOf;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
- };
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
- };
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
- mod
- ));
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
-
- // src/index.ts
- var src_exports = {};
- __export(src_exports, {
- defaultConfigureFiles: () => defaultConfigureFiles,
- loadConfiguration: () => loadConfiguration
- });
- module.exports = __toCommonJS(src_exports);
- var import_fs = __toESM(require("fs"));
- var import_path = __toESM(require("path"));
- var import_debug = __toESM(require("debug"));
- var import_jiti = __toESM(require("jiti"));
- var jiti;
- var defaultConfigureFiles = [
- "windi.config.ts",
- "windi.config.js",
- "windi.config.mjs",
- "windi.config.cjs",
- "windicss.config.ts",
- "windicss.config.js",
- "windicss.config.mjs",
- "windicss.config.cjs",
- "tailwind.config.ts",
- "tailwind.config.js",
- "tailwind.config.mjs",
- "tailwind.config.cjs"
- ];
- function loadConfiguration(options) {
- if (!jiti)
- jiti = (0, import_jiti.default)(process.cwd(), { requireCache: false, cache: false, v8cache: false });
- let resolved = {};
- let configFilePath;
- let error;
- const {
- name = "windicss-config",
- config,
- root = process.cwd(),
- configFiles: configureFiles = defaultConfigureFiles,
- onConfigurationError = (e) => {
- throw e;
- },
- onConfigurationNotFound = (path2) => {
- console.warn(`[${name}] config file "${path2}" not found, ignored`);
- }
- } = options;
- const debugConfig = (0, import_debug.default)(`${name}:config`);
- if (typeof config === "string" || !config) {
- if (!config) {
- for (const name2 of configureFiles) {
- const tryPath = import_path.default.resolve(root, name2);
- if (import_fs.default.existsSync(tryPath)) {
- configFilePath = tryPath;
- break;
- }
- }
- } else {
- configFilePath = import_path.default.resolve(root, config);
- if (!import_fs.default.existsSync(configFilePath)) {
- onConfigurationNotFound(config);
- configFilePath = void 0;
- }
- }
- if (configFilePath) {
- try {
- debugConfig("loading from ", configFilePath);
- resolved = jiti(configFilePath);
- if (resolved.default)
- resolved = resolved.default;
- } catch (e) {
- error = e;
- configFilePath = void 0;
- resolved = {};
- onConfigurationError?.(e);
- }
- }
- } else {
- resolved = config;
- }
- debugConfig(resolved);
- return {
- error,
- config: resolved,
- filepath: configFilePath
- };
- }
- // Annotate the CommonJS export names for ESM import in node:
- 0 && (module.exports = {
- defaultConfigureFiles,
- loadConfiguration
- });
|