@unocss/config 0.14.2 → 0.15.2
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.cjs +68 -0
- package/dist/index.mjs +59 -0
- package/package.json +10 -6
- package/dist/index.js +0 -94
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const unconfig = require('unconfig');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
10
|
+
|
|
11
|
+
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
12
|
+
|
|
13
|
+
function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = []) {
|
|
14
|
+
let inlineConfig = {};
|
|
15
|
+
if (typeof configOrPath !== "string") {
|
|
16
|
+
inlineConfig = configOrPath;
|
|
17
|
+
if (inlineConfig.configFile === false) {
|
|
18
|
+
return async () => ({
|
|
19
|
+
config: inlineConfig,
|
|
20
|
+
sources: []
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
configOrPath = inlineConfig.configFile || process.cwd();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const resolved = path.resolve(configOrPath);
|
|
27
|
+
let cwd = resolved;
|
|
28
|
+
let isFile = false;
|
|
29
|
+
if (fs__default.existsSync(resolved) && fs__default.statSync(resolved).isFile()) {
|
|
30
|
+
isFile = true;
|
|
31
|
+
cwd = path.dirname(resolved);
|
|
32
|
+
}
|
|
33
|
+
const loader = unconfig.createConfigLoader({
|
|
34
|
+
sources: isFile ? [
|
|
35
|
+
{
|
|
36
|
+
files: resolved,
|
|
37
|
+
extensions: []
|
|
38
|
+
}
|
|
39
|
+
] : [
|
|
40
|
+
{
|
|
41
|
+
files: [
|
|
42
|
+
"unocss.config",
|
|
43
|
+
"uno.config"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
...extraConfigSources
|
|
47
|
+
],
|
|
48
|
+
cwd,
|
|
49
|
+
defaults: inlineConfig
|
|
50
|
+
});
|
|
51
|
+
return async () => {
|
|
52
|
+
const result = await loader.load();
|
|
53
|
+
result.config = result.config || inlineConfig;
|
|
54
|
+
if (result.config.configDeps) {
|
|
55
|
+
result.sources = [
|
|
56
|
+
...result.sources,
|
|
57
|
+
...result.config.configDeps.map((i) => path.resolve(cwd, i))
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function loadConfig(dirOrPath) {
|
|
64
|
+
return createConfigLoader(dirOrPath)();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
exports.createConfigLoader = createConfigLoader;
|
|
68
|
+
exports.loadConfig = loadConfig;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { resolve, dirname } from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { createConfigLoader as createConfigLoader$1 } from 'unconfig';
|
|
4
|
+
|
|
5
|
+
function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = []) {
|
|
6
|
+
let inlineConfig = {};
|
|
7
|
+
if (typeof configOrPath !== "string") {
|
|
8
|
+
inlineConfig = configOrPath;
|
|
9
|
+
if (inlineConfig.configFile === false) {
|
|
10
|
+
return async () => ({
|
|
11
|
+
config: inlineConfig,
|
|
12
|
+
sources: []
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
configOrPath = inlineConfig.configFile || process.cwd();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const resolved = resolve(configOrPath);
|
|
19
|
+
let cwd = resolved;
|
|
20
|
+
let isFile = false;
|
|
21
|
+
if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
|
|
22
|
+
isFile = true;
|
|
23
|
+
cwd = dirname(resolved);
|
|
24
|
+
}
|
|
25
|
+
const loader = createConfigLoader$1({
|
|
26
|
+
sources: isFile ? [
|
|
27
|
+
{
|
|
28
|
+
files: resolved,
|
|
29
|
+
extensions: []
|
|
30
|
+
}
|
|
31
|
+
] : [
|
|
32
|
+
{
|
|
33
|
+
files: [
|
|
34
|
+
"unocss.config",
|
|
35
|
+
"uno.config"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
...extraConfigSources
|
|
39
|
+
],
|
|
40
|
+
cwd,
|
|
41
|
+
defaults: inlineConfig
|
|
42
|
+
});
|
|
43
|
+
return async () => {
|
|
44
|
+
const result = await loader.load();
|
|
45
|
+
result.config = result.config || inlineConfig;
|
|
46
|
+
if (result.config.configDeps) {
|
|
47
|
+
result.sources = [
|
|
48
|
+
...result.sources,
|
|
49
|
+
...result.config.configDeps.map((i) => resolve(cwd, i))
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function loadConfig(dirOrPath) {
|
|
56
|
+
return createConfigLoader(dirOrPath)();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { createConfigLoader, loadConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Config loader for UnoCSS",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/antfu/unocss/tree/main/packages/config#readme",
|
|
@@ -17,9 +17,13 @@
|
|
|
17
17
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
-
".":
|
|
20
|
+
".": {
|
|
21
|
+
"require": "./dist/index.cjs",
|
|
22
|
+
"import": "./dist/index.mjs"
|
|
23
|
+
}
|
|
21
24
|
},
|
|
22
|
-
"main": "dist/index.
|
|
25
|
+
"main": "dist/index.cjs",
|
|
26
|
+
"module": "dist/index.mjs",
|
|
23
27
|
"types": "dist/index.d.ts",
|
|
24
28
|
"files": [
|
|
25
29
|
"dist"
|
|
@@ -28,11 +32,11 @@
|
|
|
28
32
|
"node": ">=14"
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@unocss/core": "0.
|
|
35
|
+
"@unocss/core": "0.15.2",
|
|
32
36
|
"unconfig": "^0.2.2"
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"
|
|
39
|
+
"build": "unbuild",
|
|
40
|
+
"stub": "unbuild --stub"
|
|
37
41
|
}
|
|
38
42
|
}
|
package/dist/index.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, module2, desc) => {
|
|
14
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(module2))
|
|
16
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __toModule = (module2) => {
|
|
22
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// src/index.ts
|
|
26
|
-
__export(exports, {
|
|
27
|
-
LoadConfigResult: () => import_unconfig.LoadConfigResult,
|
|
28
|
-
LoadConfigSource: () => import_unconfig.LoadConfigSource,
|
|
29
|
-
createConfigLoader: () => createConfigLoader,
|
|
30
|
-
loadConfig: () => loadConfig
|
|
31
|
-
});
|
|
32
|
-
var import_path = __toModule(require("path"));
|
|
33
|
-
var import_fs = __toModule(require("fs"));
|
|
34
|
-
var import_unconfig = __toModule(require("unconfig"));
|
|
35
|
-
function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = []) {
|
|
36
|
-
let inlineConfig = {};
|
|
37
|
-
if (typeof configOrPath !== "string") {
|
|
38
|
-
inlineConfig = configOrPath;
|
|
39
|
-
if (inlineConfig.configFile === false) {
|
|
40
|
-
return async () => ({
|
|
41
|
-
config: inlineConfig,
|
|
42
|
-
sources: []
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
configOrPath = inlineConfig.configFile || process.cwd();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const resolved = (0, import_path.resolve)(configOrPath);
|
|
49
|
-
let cwd = resolved;
|
|
50
|
-
let isFile = false;
|
|
51
|
-
if (import_fs.default.existsSync(resolved) && import_fs.default.statSync(resolved).isFile()) {
|
|
52
|
-
isFile = true;
|
|
53
|
-
cwd = (0, import_path.dirname)(resolved);
|
|
54
|
-
}
|
|
55
|
-
const loader = (0, import_unconfig.createConfigLoader)({
|
|
56
|
-
sources: isFile ? [
|
|
57
|
-
{
|
|
58
|
-
files: resolved,
|
|
59
|
-
extensions: []
|
|
60
|
-
}
|
|
61
|
-
] : [
|
|
62
|
-
{
|
|
63
|
-
files: [
|
|
64
|
-
"unocss.config",
|
|
65
|
-
"uno.config"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
...extraConfigSources
|
|
69
|
-
],
|
|
70
|
-
cwd,
|
|
71
|
-
defaults: inlineConfig
|
|
72
|
-
});
|
|
73
|
-
return async () => {
|
|
74
|
-
const result = await loader.load();
|
|
75
|
-
result.config = result.config || inlineConfig;
|
|
76
|
-
if (result.config.configDeps) {
|
|
77
|
-
result.sources = [
|
|
78
|
-
...result.sources,
|
|
79
|
-
...result.config.configDeps.map((i) => (0, import_path.resolve)(cwd, i))
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function loadConfig(dirOrPath) {
|
|
86
|
-
return createConfigLoader(dirOrPath)();
|
|
87
|
-
}
|
|
88
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
-
0 && (module.exports = {
|
|
90
|
-
LoadConfigResult,
|
|
91
|
-
LoadConfigSource,
|
|
92
|
-
createConfigLoader,
|
|
93
|
-
loadConfig
|
|
94
|
-
});
|