-
-
Notifications
You must be signed in to change notification settings - Fork 284
/
config.ts
229 lines (219 loc) · 5.62 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import type { PluginItem as BabelPluginItem } from '@babel/core'
import type { RollupBabelInputPluginOptions } from '@rollup/plugin-babel'
import type { Plugin as PostCssPlugin } from 'postcss'
import type { CSSOptions, PluginOption, ServerOptions, UserConfig as ViteConfig } from 'vite'
import type { Options, compilation } from 'webpack'
import type WebpackChainConfig from 'webpack-chain'
import { ISSRContext } from './ctx'
import { Argv } from './yargs'
export type PluginItem = BabelPluginItem
export interface SSRModule extends compilation.Module {
resource?: string
dependencies?: Array<{ request: string }>
nameForCondition?: () => string
}
export interface PkgJson {
name: string
version: string
dependencies?: Record<string, string>
devDependencies?: Record<string, string>
}
export type Chain = WebpackChainConfig
export type Script = Array<{
tagName?: string
describe?:
| object
| {
attrs: object
}
content?: string
}>
export type Json = string | number | boolean | { [key: string]: Json } | undefined
export interface IConfig {
rootId: string
cwd: string
alias?: Record<string, string>
isDev: boolean
dynamic: boolean
publicPath: string
useHash: boolean
host: string
fePort: number
serverPort: number
chunkName: string
getOutput: () => {
clientOutPut: string
serverOutPut: string
}
cssInline?: 'all' | string[]
jsInline?: 'all' | string[]
assetsDir?: string
proxy?: any
cssOrder: string[]
jsOrder: string[]
extraJsOrder?: ((ctx: ISSRContext) => string[]) | string[] | undefined
extraCssOrder?: ((ctx: ISSRContext) => string[]) | string[] | undefined
jsOrderPriority?: Record<string, number> | ((params: { chunkName: string }) => Record<string, number>)
cssOrderPriority?: Record<string, number> | ((params: { chunkName: string }) => Record<string, number>)
css?: () => {
loaderOptions?: {
cssOptions?: any
less?: {
/**
* transfer options to less
*/
lessOptions?: any
/**
* The following options options only take effect in webpack
*/
additionalData?: string | Function
sourceMap?: boolean
webpackImporter?: Boolean
implementation?: Object
}
/**
* only take effect in webpack
*/
sass?: any
/**
* only take effect in vite
*/
scss?: any
postcss?: {
options?: Exclude<CSSOptions['postcss'], string>
plugins?: PostCssPlugin[]
}
}
}
chainBaseConfig: (config: Chain, isServer: boolean) => void
chainServerConfig: (config: Chain) => void
chainClientConfig: (config: Chain) => void
webpackStatsOption: Options.Stats
moduleFileExtensions: string[]
whiteList: Array<RegExp | string>
cloudIDE?: boolean
prefix: string
clientPrefix?: string
mode: 'ssr' | 'csr'
webpackDevServerConfig?: any
stream: boolean
bigpipe?: boolean
customeHeadScript?: ((ctx: ISSRContext) => Script) | Script
customeFooterScript?: ((ctx: ISSRContext) => Script) | Script
locale?: {
enable: boolean
}
ssrVueLoaderOptions?: any
csrVueLoaderOptions?: any
corejs?: boolean
corejsOptions?: Object
https: boolean | object
babelExtraModule?: RegExp[]
routerPriority?: Record<string, number>
routerOptimize?: {
include?: string[]
exclude?: string[]
}
parallelFetch?: boolean
nestStartTips?: string
manifestPath: string
proxyKey: string[]
vue3ServerEntry: string
vue3ClientEntry: string
vueServerEntry: string
vueClientEntry: string
reactServerEntry: string
reactClientEntry: string
react18ServerEntry: string
react18ClientEntry: string
isVite: boolean
optimize: boolean
supportOptinalChaining: boolean
onError?: (e: any) => null | string
onReady?: () => any
viteConfig?: () => {
common?: {
// 双端通用配置
extraPlugin?: PluginOption | PluginOption[]
server?: ServerOptions
}
client?: {
/**
* 默认装载的插件定义 options, vue3 场景是 @vitejs/plugin-vue, react 场景是 @vitejs/plugin-react
*/
defaultPluginOptions?: any
extraPlugin?: PluginOption | PluginOption[]
otherConfig?: ViteConfig
processPlugin?: (plugins: PluginOption[]) => PluginOption[]
}
server?: {
externals?: string[]
defaultPluginOptions?: any
extraPlugin?: PluginOption | PluginOption[]
otherConfig?: ViteConfig
processPlugin?: (plugins: PluginOption[]) => PluginOption[]
}
}
hmr?: {
host?: string
port?: number
}
define?: {
base?: Record<string, string>
client?: Record<string, string>
server?: Record<string, string>
}
babelOptions?: RollupBabelInputPluginOptions & {
include?: RegExp[]
}
hashRouter?: boolean
htmlTemplate?: string
writeDebounceTime: number
dynamicFile: {
serverBundle: string
asyncChunkMap: string
assetManifest: string
configFile?: string
}
staticConfigPath: string
framework?: string
/**
* react场景设置默认的stream缓冲区大小默认为 16kb,当页面体积过大超过限制时会渲染失败,单位byte,(1024*1024 = 1mb)
*/
streamHighWaterMark?: number
asyncGlobalData?: Record<string, any>
wrapMicroScope?: boolean
clientHistoryRouterMode?: 'webHistory' | 'memoryHistory'
}
export interface proxyOptions {
express?: boolean
}
export type UserConfig = Partial<IConfig>
export interface StyleOptions {
rule: string
include?: RegExp | RegExp[]
exclude?: RegExp | RegExp[]
loader?: string
importLoaders: number
isServer: boolean
}
export interface IPlugin {
clientPlugin?: {
name: string
start?: (argv?: Argv) => void
build?: (argv?: Argv) => void
deploy?: (argv?: Argv) => void
}
serverPlugin?: {
name: string
start?: (argv?: Argv) => void
build?: (argv?: Argv) => void
deploy?: (argv?: Argv) => void
}
}
export interface Vue3RenderRes {
html: string
teleportsContext: {
teleports?: Record<string, string> | undefined
}
}