@@ -11,7 +11,10 @@ import {
11
11
import type { AppNormalizedConfig , AppTools } from '../types' ;
12
12
import { loadServerPlugins } from '../utils/loadPlugins' ;
13
13
import { printInstructions } from '../utils/printInstructions' ;
14
- import type { ExtraServerOptions } from './dev' ;
14
+
15
+ type ExtraServerOptions = {
16
+ launcher ?: typeof createProdServer ;
17
+ } ;
15
18
16
19
export const serve = async (
17
20
api : CLIPluginAPI < AppTools < 'shared' > > ,
@@ -54,50 +57,47 @@ export const serve = async (
54
57
55
58
const pluginInstances = await loadServerPlugins ( api , appDirectory , metaName ) ;
56
59
57
- const app = await createProdServer (
58
- {
59
- metaName,
60
- pwd : distDirectory ,
61
- config : {
62
- ...userConfig ,
63
- dev : userConfig . dev as any ,
64
- // server-core can't get RegExp & Function output.enableInlineScripts by JSON.stringy;
65
- output : {
66
- path : userConfig . output . distPath ?. root ,
67
- ...( userConfig . output || { } ) ,
68
- } as any ,
69
- } ,
70
- routes : serverRoutes ,
71
- plugins : pluginInstances ,
72
- serverConfigFile,
73
- serverConfigPath,
74
- appContext : {
75
- appDirectory,
76
- internalDirectory,
77
- sharedDirectory : getTargetDir (
78
- appContext . sharedDirectory ,
79
- appContext . appDirectory ,
80
- appContext . distDirectory ,
81
- ) ,
82
- apiDirectory : isCrossProjectServer
83
- ? appContext . apiDirectory
84
- : getTargetDir (
85
- appContext . apiDirectory ,
86
- appContext . appDirectory ,
87
- appContext . distDirectory ,
88
- ) ,
89
- lambdaDirectory : isCrossProjectServer
90
- ? appContext . lambdaDirectory
91
- : getTargetDir (
92
- appContext . lambdaDirectory ,
93
- appContext . appDirectory ,
94
- appContext . distDirectory ,
95
- ) ,
96
- } ,
97
- runMode,
60
+ const app = await ( serverOptions ?. launcher || createProdServer ) ( {
61
+ metaName,
62
+ pwd : distDirectory ,
63
+ config : {
64
+ ...userConfig ,
65
+ dev : userConfig . dev as any ,
66
+ // server-core can't get RegExp & Function output.enableInlineScripts by JSON.stringy;
67
+ output : {
68
+ path : userConfig . output . distPath ?. root ,
69
+ ...( userConfig . output || { } ) ,
70
+ } as any ,
98
71
} ,
99
- serverOptions ?. applyPlugins ,
100
- ) ;
72
+ routes : serverRoutes ,
73
+ plugins : pluginInstances ,
74
+ serverConfigFile,
75
+ serverConfigPath,
76
+ appContext : {
77
+ appDirectory,
78
+ internalDirectory,
79
+ sharedDirectory : getTargetDir (
80
+ appContext . sharedDirectory ,
81
+ appContext . appDirectory ,
82
+ appContext . distDirectory ,
83
+ ) ,
84
+ apiDirectory : isCrossProjectServer
85
+ ? appContext . apiDirectory
86
+ : getTargetDir (
87
+ appContext . apiDirectory ,
88
+ appContext . appDirectory ,
89
+ appContext . distDirectory ,
90
+ ) ,
91
+ lambdaDirectory : isCrossProjectServer
92
+ ? appContext . lambdaDirectory
93
+ : getTargetDir (
94
+ appContext . lambdaDirectory ,
95
+ appContext . appDirectory ,
96
+ appContext . distDirectory ,
97
+ ) ,
98
+ } ,
99
+ runMode,
100
+ } ) ;
101
101
102
102
app . listen ( port , async ( ) => {
103
103
await printInstructions (
0 commit comments