File tree 3 files changed +28
-2
lines changed
packages/@vuepress/core/lib
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
25
25
return console . error ( logger . error ( chalk . red ( 'Unexpected option: outDir cannot be set to the current working directory.\n' ) , false ) )
26
26
}
27
27
await fs . remove ( outDir )
28
+ logger . debug ( 'Dist directory: ' + chalk . gray ( path . resolve ( outDir ) ) )
28
29
29
30
let clientConfig = createClientConfig ( options , cliOptions ) . toConfig ( )
30
31
let serverConfig = createServerConfig ( options , cliOptions ) . toConfig ( )
@@ -56,7 +57,7 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
56
57
runInNewContext : false ,
57
58
inject : false ,
58
59
shouldPrefetch : options . siteConfig . shouldPrefetch || ( ( ) => true ) ,
59
- template : await fs . readFile ( path . resolve ( __dirname , 'app/index.ssr.html' ) , 'utf-8' )
60
+ template : await fs . readFile ( options . ssrTemplate , 'utf-8' )
60
61
} )
61
62
62
63
// pre-render head tags from user config
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
65
65
// using a fork of html-webpack-plugin to avoid it requiring webpack
66
66
// internals from an incompatible version.
67
67
. use ( require ( 'vuepress-html-webpack-plugin' ) , [ {
68
- template : path . resolve ( __dirname , 'app/index.dev.html' )
68
+ template : options . devTemplate
69
69
} ] )
70
70
71
71
config
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ module.exports = class AppContext {
48
48
*/
49
49
async process ( ) {
50
50
this . normalizeHeadTagUrls ( )
51
+ this . resolveTemplates ( )
51
52
await this . resolveTheme ( )
52
53
this . resolvePlugins ( )
53
54
@@ -124,6 +125,30 @@ module.exports = class AppContext {
124
125
}
125
126
}
126
127
128
+ /**
129
+ * Make template configurable
130
+ */
131
+ resolveTemplates ( ) {
132
+ let { ssrTemplate, devTemplate } = this . siteConfig
133
+ const templateDir = path . resolve ( this . vuepressDir , 'templates' )
134
+ if ( ! devTemplate ) {
135
+ devTemplate = path . resolve ( templateDir , 'dev.html' )
136
+ if ( ! fs . existsSync ( devTemplate ) ) {
137
+ devTemplate = path . resolve ( __dirname , '../app/index.dev.html' )
138
+ }
139
+ }
140
+ if ( ! ssrTemplate ) {
141
+ ssrTemplate = path . resolve ( templateDir , 'ssr.html' )
142
+ if ( ! fs . existsSync ( ssrTemplate ) ) {
143
+ ssrTemplate = path . resolve ( __dirname , '../app/index.ssr.html' )
144
+ }
145
+ }
146
+ logger . debug ( 'SSR Template File: ' + chalk . gray ( ssrTemplate ) )
147
+ logger . debug ( 'DEV Template File: ' + chalk . gray ( devTemplate ) )
148
+ this . devTemplate = devTemplate
149
+ this . ssrTemplate = ssrTemplate
150
+ }
151
+
127
152
/**
128
153
* Find all page source files located in sourceDir
129
154
* @returns {Promise<void> }
You can’t perform that action at this time.
0 commit comments