@@ -17,9 +17,7 @@ const defaultOptions: AppOptions = {
17
17
'public-dir' : undefined ,
18
18
'static-dir' : undefined ,
19
19
spa : undefined ,
20
- 'not-found-page' : ( options ) => {
21
- return options [ 'public-dir' ] + '/404.html' ;
22
- } ,
20
+ 'not-found-page' : '[public-dir]/404.html' ,
23
21
'auto-index' : [ 'index.html' , 'index.htm' ] ,
24
22
'auto-ext' : [ '.html' , '.htm' ] ,
25
23
@@ -42,6 +40,13 @@ function pickKeys(keys: string[], object: Record<string, any>): Record<string, a
42
40
43
41
}
44
42
43
+ function applyPublicDir ( optionValue : string | null | undefined , publicDir : string ) {
44
+ if ( optionValue == null ) {
45
+ return optionValue ;
46
+ }
47
+ return optionValue . replace ( '[public-dir]' , publicDir ) ;
48
+ }
49
+
45
50
export function initApp ( commandLineValues : CommandLineOptions ) {
46
51
47
52
let options : AppOptions = defaultOptions ;
@@ -75,11 +80,6 @@ export function initApp(commandLineValues: CommandLineOptions) {
75
80
...pickKeys ( [ 'public-dir' , 'static-dir' , 'spa' , 'not-found-page' , 'auto-index' , 'auto-ext' , 'author' , 'name' , 'description' , 'service-id' ] , commandLineValues )
76
81
} ;
77
82
78
- if ( typeof options [ 'not-found-page' ] === 'function' ) {
79
- // Apply function for this one
80
- options [ 'not-found-page' ] = options [ 'not-found-page' ] ( options ) ;
81
- }
82
-
83
83
if ( preset != null ) {
84
84
if ( ! preset . check ( packageJson , options ) ) {
85
85
console . log ( "Failed preset check." ) ;
@@ -98,11 +98,11 @@ export function initApp(commandLineValues: CommandLineOptions) {
98
98
}
99
99
const publicDir = path . resolve ( PUBLIC_DIR ) ;
100
100
101
- const BUILD_STATIC_DIR = options [ 'static-dir' ] ;
101
+ const BUILD_STATIC_DIR = applyPublicDir ( options [ 'static-dir' ] , PUBLIC_DIR ) ;
102
102
const buildStaticDir = BUILD_STATIC_DIR != null ? path . resolve ( BUILD_STATIC_DIR ) : null ;
103
103
104
- const spa = options [ 'spa' ] ;
105
- const notFoundPage = options [ 'not-found-page' ] ;
104
+ const spa = applyPublicDir ( options [ 'spa' ] , PUBLIC_DIR ) ;
105
+ const notFoundPage = applyPublicDir ( options [ 'not-found-page' ] , PUBLIC_DIR ) ;
106
106
107
107
const autoIndex = options [ 'auto-index' ] ;
108
108
const autoExt = options [ 'auto-ext' ] ;
0 commit comments