Skip to content

Commit daa763e

Browse files
committed
fix: fix --docs options issue.
1 parent 70e5409 commit daa763e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

core/src/plugins/staticDoc.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ export function getDocsData(str: string = '') {
1717
route = '/' + route;
1818
}
1919
const [_, name] = dirPath.match(/^([a-zA-Z]+|@[a-zA-Z]+\/[a-zA-Z]+)\/?/i);
20+
const pkgPath = resolvePackagePath(name, process.cwd());
21+
const root = path.dirname(pkgPath).replace(new RegExp(`${name.replace('/', path.sep)}$`, 'ig'), '');
22+
const [repath] = str.replace(name, '').split(':');
23+
const docRoot = path.resolve(path.dirname(pkgPath) + repath);
2024
return {
2125
name,
2226
route,
2327
dirPath,
28+
pkgPath,
29+
root,
30+
docRoot,
2431
};
2532
}
2633

@@ -34,12 +41,7 @@ export const staticDocSetupMiddlewares = (
3441
options: StartArgs & DevServerOptions,
3542
) => {
3643
if (options.docs) {
37-
const { name, route, dirPath } = getDocsData(options.docs);
38-
const pkgPath = resolvePackagePath(name, process.cwd());
39-
const docRoot = path.resolve(
40-
path.dirname(pkgPath).replace(new RegExp(`${name.replace('/', path.sep)}$`, 'ig'), ''),
41-
dirPath,
42-
);
44+
const { route, docRoot } = getDocsData(options.docs);
4345
devServer.app.use(route, express.static(docRoot));
4446
}
4547
return middlewares;

0 commit comments

Comments
 (0)