@@ -20,12 +20,12 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
20
20
const { frontmatterEmitter } = require ( '@vuepress/markdown-loader' )
21
21
22
22
logger . wait ( '\nExtracting site metadata...' )
23
- const options = await prepare ( sourceDir , cliOptions , false /* isProd */ )
23
+ const ctx = await prepare ( sourceDir , cliOptions , false /* isProd */ )
24
24
25
25
// setup watchers to update options and dynamically generated files
26
26
const update = ( reason ) => {
27
27
logger . debug ( `Re-prepare due to ${ chalk . cyan ( reason ) } ` )
28
- options . pluginAPI . options . updated . syncApply ( )
28
+ ctx . pluginAPI . options . updated . syncApply ( )
29
29
prepare ( sourceDir , cliOptions , false /* isProd */ ) . catch ( err => {
30
30
console . error ( logger . error ( chalk . red ( err . stack ) , false ) )
31
31
} )
@@ -60,35 +60,35 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
60
60
frontmatterEmitter . on ( 'update' , ( ) => update ( 'frontmatter or headers change' ) )
61
61
62
62
// resolve webpack config
63
- let config = createClientConfig ( options )
63
+ let config = createClientConfig ( ctx )
64
64
65
65
config
66
66
. plugin ( 'html' )
67
67
// using a fork of html-webpack-plugin to avoid it requiring webpack
68
68
// internals from an incompatible version.
69
69
. use ( require ( 'vuepress-html-webpack-plugin' ) , [ {
70
- template : options . devTemplate
70
+ template : ctx . devTemplate
71
71
} ] )
72
72
73
73
config
74
74
. plugin ( 'site-data' )
75
75
. use ( HeadPlugin , [ {
76
- tags : options . siteConfig . head || [ ]
76
+ tags : ctx . siteConfig . head || [ ]
77
77
} ] )
78
78
79
- const port = await resolvePort ( cliOptions . port || options . siteConfig . port )
80
- const { host, displayHost } = await resolveHost ( cliOptions . host || options . siteConfig . host )
79
+ const port = await resolvePort ( cliOptions . port || ctx . siteConfig . port )
80
+ const { host, displayHost } = await resolveHost ( cliOptions . host || ctx . siteConfig . host )
81
81
82
82
config
83
83
. plugin ( 'vuepress-log' )
84
84
. use ( DevLogPlugin , [ {
85
85
port,
86
86
displayHost,
87
- publicPath : options . base
87
+ publicPath : ctx . base
88
88
} ] )
89
89
90
90
config = config . toConfig ( )
91
- const userConfig = options . siteConfig . configureWebpack
91
+ const userConfig = ctx . siteConfig . configureWebpack
92
92
if ( userConfig ) {
93
93
config = applyUserWebpackConfig ( userConfig , config , false /* isServer */ )
94
94
}
@@ -111,8 +111,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
111
111
port,
112
112
add : app => {
113
113
// apply plugin options to extend dev server.
114
- const { pluginAPI } = options
115
- pluginAPI . options . enhanceDevServer . syncApply ( app )
114
+ ctx . pluginAPI . options . enhanceDevServer . syncApply ( app )
116
115
117
116
const userPublic = path . resolve ( sourceDir , '.vuepress/public' )
118
117
@@ -121,7 +120,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
121
120
122
121
// respect base when serving static files...
123
122
if ( fs . existsSync ( userPublic ) ) {
124
- app . use ( mount ( options . base , serveStatic ( userPublic ) ) )
123
+ app . use ( mount ( ctx . base , serveStatic ( userPublic ) ) )
125
124
}
126
125
127
126
app . use ( convert ( history ( {
0 commit comments