版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

115 строки
3.5 KiB

  1. "use strict";
  2. var __create = Object.create;
  3. var __defProp = Object.defineProperty;
  4. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  5. var __getOwnPropNames = Object.getOwnPropertyNames;
  6. var __getProtoOf = Object.getPrototypeOf;
  7. var __hasOwnProp = Object.prototype.hasOwnProperty;
  8. var __export = (target, all) => {
  9. for (var name in all)
  10. __defProp(target, name, { get: all[name], enumerable: true });
  11. };
  12. var __copyProps = (to, from, except, desc) => {
  13. if (from && typeof from === "object" || typeof from === "function") {
  14. for (let key of __getOwnPropNames(from))
  15. if (!__hasOwnProp.call(to, key) && key !== except)
  16. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  17. }
  18. return to;
  19. };
  20. var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  21. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  22. mod
  23. ));
  24. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  25. // src/index.ts
  26. var src_exports = {};
  27. __export(src_exports, {
  28. defaultConfigureFiles: () => defaultConfigureFiles,
  29. loadConfiguration: () => loadConfiguration
  30. });
  31. module.exports = __toCommonJS(src_exports);
  32. var import_fs = __toESM(require("fs"));
  33. var import_path = __toESM(require("path"));
  34. var import_debug = __toESM(require("debug"));
  35. var import_jiti = __toESM(require("jiti"));
  36. var jiti;
  37. var defaultConfigureFiles = [
  38. "windi.config.ts",
  39. "windi.config.js",
  40. "windi.config.mjs",
  41. "windi.config.cjs",
  42. "windicss.config.ts",
  43. "windicss.config.js",
  44. "windicss.config.mjs",
  45. "windicss.config.cjs",
  46. "tailwind.config.ts",
  47. "tailwind.config.js",
  48. "tailwind.config.mjs",
  49. "tailwind.config.cjs"
  50. ];
  51. function loadConfiguration(options) {
  52. if (!jiti)
  53. jiti = (0, import_jiti.default)(process.cwd(), { requireCache: false, cache: false, v8cache: false });
  54. let resolved = {};
  55. let configFilePath;
  56. let error;
  57. const {
  58. name = "windicss-config",
  59. config,
  60. root = process.cwd(),
  61. configFiles: configureFiles = defaultConfigureFiles,
  62. onConfigurationError = (e) => {
  63. throw e;
  64. },
  65. onConfigurationNotFound = (path2) => {
  66. console.warn(`[${name}] config file "${path2}" not found, ignored`);
  67. }
  68. } = options;
  69. const debugConfig = (0, import_debug.default)(`${name}:config`);
  70. if (typeof config === "string" || !config) {
  71. if (!config) {
  72. for (const name2 of configureFiles) {
  73. const tryPath = import_path.default.resolve(root, name2);
  74. if (import_fs.default.existsSync(tryPath)) {
  75. configFilePath = tryPath;
  76. break;
  77. }
  78. }
  79. } else {
  80. configFilePath = import_path.default.resolve(root, config);
  81. if (!import_fs.default.existsSync(configFilePath)) {
  82. onConfigurationNotFound(config);
  83. configFilePath = void 0;
  84. }
  85. }
  86. if (configFilePath) {
  87. try {
  88. debugConfig("loading from ", configFilePath);
  89. resolved = jiti(configFilePath);
  90. if (resolved.default)
  91. resolved = resolved.default;
  92. } catch (e) {
  93. error = e;
  94. configFilePath = void 0;
  95. resolved = {};
  96. onConfigurationError?.(e);
  97. }
  98. }
  99. } else {
  100. resolved = config;
  101. }
  102. debugConfig(resolved);
  103. return {
  104. error,
  105. config: resolved,
  106. filepath: configFilePath
  107. };
  108. }
  109. // Annotate the CommonJS export names for ESM import in node:
  110. 0 && (module.exports = {
  111. defaultConfigureFiles,
  112. loadConfiguration
  113. });