sdocs 0.0.22 → 0.0.23
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/server/config.d.ts +4 -0
- package/dist/server/config.js +12 -4
- package/dist/vite.js +4 -7
- package/package.json +1 -1
package/dist/server/config.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { SdocsConfig, ResolvedSdocsConfig } from '../types.js';
|
|
2
2
|
/** Find the config file path in the given directory */
|
|
3
3
|
export declare function findConfigFile(root: string): string | null;
|
|
4
|
+
/** Load the raw config from file (unresolved) */
|
|
5
|
+
export declare function loadRawConfig(root: string): Promise<SdocsConfig>;
|
|
4
6
|
/** Load and resolve the sdocs config with defaults */
|
|
5
7
|
export declare function loadConfig(root: string): Promise<ResolvedSdocsConfig>;
|
|
8
|
+
/** Resolve config and finalize paths */
|
|
9
|
+
export declare function resolveAndFinalize(userConfig: SdocsConfig, root: string): ResolvedSdocsConfig;
|
|
6
10
|
/** Merge user config with defaults */
|
|
7
11
|
export declare function resolveConfig(userConfig: SdocsConfig): ResolvedSdocsConfig;
|
package/dist/server/config.js
CHANGED
|
@@ -39,12 +39,20 @@ function resolveCssPaths(css, root) {
|
|
|
39
39
|
}
|
|
40
40
|
return resolved;
|
|
41
41
|
}
|
|
42
|
-
/** Load
|
|
43
|
-
export async function
|
|
42
|
+
/** Load the raw config from file (unresolved) */
|
|
43
|
+
export async function loadRawConfig(root) {
|
|
44
44
|
const configPath = findConfigFile(root);
|
|
45
45
|
if (!configPath)
|
|
46
|
-
return {
|
|
47
|
-
|
|
46
|
+
return {};
|
|
47
|
+
return importConfig(configPath);
|
|
48
|
+
}
|
|
49
|
+
/** Load and resolve the sdocs config with defaults */
|
|
50
|
+
export async function loadConfig(root) {
|
|
51
|
+
const rawConfig = await loadRawConfig(root);
|
|
52
|
+
return resolveAndFinalize(rawConfig, root);
|
|
53
|
+
}
|
|
54
|
+
/** Resolve config and finalize paths */
|
|
55
|
+
export function resolveAndFinalize(userConfig, root) {
|
|
48
56
|
const resolved = resolveConfig(userConfig);
|
|
49
57
|
resolved.include = resolveIncludePatterns(resolved.include, root);
|
|
50
58
|
resolved.css = resolveCssPaths(resolved.css, root);
|
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import {
|
|
2
|
+
import { loadRawConfig, resolveAndFinalize } from './server/config.js';
|
|
3
3
|
import { discoverDocFiles, getSdocKind } from './server/discovery.js';
|
|
4
4
|
import { parseDocSource } from './server/meta-parser.js';
|
|
5
5
|
import { parseComponent } from './server/prop-parser.js';
|
|
@@ -22,12 +22,9 @@ export function sdocsPlugin(userConfig) {
|
|
|
22
22
|
name: 'sdocs',
|
|
23
23
|
async configResolved(resolvedConfig) {
|
|
24
24
|
root = resolvedConfig.root;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
else {
|
|
29
|
-
config = await loadConfig(root);
|
|
30
|
-
}
|
|
25
|
+
const fileConfig = await loadRawConfig(root);
|
|
26
|
+
const merged = { ...fileConfig, ...userConfig };
|
|
27
|
+
config = resolveAndFinalize(merged, root);
|
|
31
28
|
},
|
|
32
29
|
configureServer(devServer) {
|
|
33
30
|
server = devServer;
|