@unocss/config 66.6.0-beta.1 → 66.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +6 -2
- package/package.json +7 -9
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
|
+
import { cyan } from "colorette";
|
|
5
|
+
import { consola } from "consola";
|
|
4
6
|
import { createConfigLoader } from "unconfig";
|
|
5
7
|
|
|
6
8
|
//#region src/index.ts
|
|
7
9
|
async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = [], defaults = {}) {
|
|
10
|
+
var _result$sources;
|
|
8
11
|
let inlineConfig = {};
|
|
9
12
|
if (typeof configOrPath !== "string") {
|
|
10
13
|
inlineConfig = configOrPath;
|
|
@@ -19,7 +22,7 @@ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSo
|
|
|
19
22
|
if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
|
|
20
23
|
isFile = true;
|
|
21
24
|
cwd = dirname(resolved);
|
|
22
|
-
}
|
|
25
|
+
} else if (/\.(?:ts|js|mjs|cjs|mts)$/.test(configOrPath) && resolve(configOrPath) !== resolve(cwd)) throw new Error(`[@unocss/config] Custom config file not found: ${cyan(configOrPath)}. Please check the path and try again.`);
|
|
23
26
|
const result = await createConfigLoader({
|
|
24
27
|
sources: isFile ? [{
|
|
25
28
|
files: resolved,
|
|
@@ -28,6 +31,7 @@ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSo
|
|
|
28
31
|
cwd,
|
|
29
32
|
defaults: inlineConfig
|
|
30
33
|
}).load();
|
|
34
|
+
if (!isFile && !((_result$sources = result.sources) === null || _result$sources === void 0 ? void 0 : _result$sources.length)) consola.error(`[@unocss/config] Config file not found in ${cyan(configOrPath)} - loading default config.`);
|
|
31
35
|
result.config = Object.assign(defaults, inlineConfig, result.config ?? {});
|
|
32
36
|
if (result.config.configDeps) result.sources = [...result.sources, ...result.config.configDeps.map((i) => resolve(cwd, i))];
|
|
33
37
|
return result;
|
|
@@ -48,7 +52,7 @@ function createRecoveryConfigLoader() {
|
|
|
48
52
|
return config;
|
|
49
53
|
} catch (e) {
|
|
50
54
|
if (lastResolved) {
|
|
51
|
-
|
|
55
|
+
consola.error(`[@unocss/config] Error loading config:`, e);
|
|
52
56
|
return lastResolved;
|
|
53
57
|
}
|
|
54
58
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.6.
|
|
4
|
+
"version": "66.6.1",
|
|
5
5
|
"description": "Config loader for UnoCSS",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,13 +18,9 @@
|
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"exports": {
|
|
21
|
-
".":
|
|
22
|
-
|
|
23
|
-
"default": "./dist/index.mjs"
|
|
24
|
-
}
|
|
21
|
+
".": "./dist/index.mjs",
|
|
22
|
+
"./package.json": "./package.json"
|
|
25
23
|
},
|
|
26
|
-
"main": "dist/index.mjs",
|
|
27
|
-
"module": "dist/index.mjs",
|
|
28
24
|
"types": "dist/index.d.mts",
|
|
29
25
|
"files": [
|
|
30
26
|
"dist"
|
|
@@ -33,8 +29,10 @@
|
|
|
33
29
|
"node": ">=14"
|
|
34
30
|
},
|
|
35
31
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
32
|
+
"colorette": "^2.0.20",
|
|
33
|
+
"consola": "^3.4.2",
|
|
34
|
+
"unconfig": "^7.5.0",
|
|
35
|
+
"@unocss/core": "66.6.1"
|
|
38
36
|
},
|
|
39
37
|
"scripts": {
|
|
40
38
|
"build": "tsdown",
|