1
1
import { join } from "node:path" ;
2
2
import { createRequire } from "node:module" ;
3
- import { createDevApp , defaultTheme , viteBundler } from "vuepress" ;
3
+ import {
4
+ createDevApp ,
5
+ defaultTheme ,
6
+ loadUserConfig ,
7
+ resolveUserConfigConventionalPath as resolveVuePressConfig ,
8
+ transformUserConfigToPlugin ,
9
+ viteBundler ,
10
+ } from "vuepress" ;
4
11
import debug from "debug" ;
5
12
import type { CommandOptions } from "@condorhero/vuepress-plugin-export-pdf-core" ;
6
- import { checkEnv , generatePdf , loadModule , resolveUserConfigConventionalPath , resolveUserConfigPath , timeTransformer } from "@condorhero/vuepress-plugin-export-pdf-core" ;
13
+ import {
14
+ checkEnv , generatePdf ,
15
+ loadModule ,
16
+ resolveUserConfigConventionalPath ,
17
+ resolveUserConfigPath ,
18
+ timeTransformer ,
19
+ } from "@condorhero/vuepress-plugin-export-pdf-core" ;
7
20
8
21
import pkg from "../package.json" ;
9
22
import type { UserConfig } from "." ;
@@ -45,8 +58,8 @@ export const serverApp = async (dir = "docs", commandOptions: CommandOptions = {
45
58
devDebug ( "userConfig: %O" , userConfig ) ;
46
59
47
60
const {
48
- theme = defaultTheme ( ) ,
49
- bundler = viteBundler ( ) ,
61
+ theme,
62
+ bundler,
50
63
sorter,
51
64
puppeteerLaunchOptions,
52
65
pdfOptions,
@@ -58,14 +71,20 @@ export const serverApp = async (dir = "docs", commandOptions: CommandOptions = {
58
71
outlineContainerSelector,
59
72
} = userConfig ;
60
73
74
+ const { userConfig : vuePressConfig } = await loadUserConfig ( resolveVuePressConfig ( sourceDir ) ) ;
75
+
61
76
const devApp = createDevApp ( {
62
77
source : sourceDir ,
63
- bundler,
64
- theme,
78
+ ...vuePressConfig ,
79
+ bundler : bundler || vuePressConfig . bundler || viteBundler ( ) ,
80
+ theme : theme || vuePressConfig . theme || defaultTheme ( ) ,
65
81
host : "localhost" ,
66
82
port : 8714 ,
67
83
} ) ;
68
84
85
+ // use user-config plugin
86
+ devApp . use ( transformUserConfigToPlugin ( userConfig , sourceDir ) ) ;
87
+
69
88
// initialize and prepare
70
89
await devApp . init ( ) ;
71
90
await devApp . prepare ( ) ;
0 commit comments