@@ -44,6 +44,13 @@ The `InlineConfig` interface extends `UserConfig` with additional properties:
44
44
- ` configFile ` : specify config file to use . If not set , Vite will try to automatically resolve one from project root . Set to ` false ` to disable auto resolving .
45
45
- ` envFile ` : Set to ` false ` to disable ` .env ` files .
46
46
47
+ ## ` ResolvedConfig `
48
+
49
+ The ` ResolvedConfig ` interface has all the same properties of a ` UserConfig ` , except most properties are resolved and non - undefined . It also contains utilities like :
50
+
51
+ - ` config.assetsInclude ` : A function to check if an `id` is considered an asset.
52
+ - `config.logger`: Vite's internal logger object.
53
+
47
54
## `ViteDevServer`
48
55
49
56
```ts
@@ -189,12 +196,74 @@ import { preview } from 'vite'
189
196
async function resolveConfig(
190
197
inlineConfig: InlineConfig,
191
198
command: 'build' | 'serve',
192
- defaultMode?: string
199
+ defaultMode = 'development'
193
200
): Promise<ResolvedConfig>
194
201
` ` `
195
202
196
203
The ` command ` value is ` serve ` in dev (in the cli ` vite ` , ` vite dev ` , and ` vite serve ` are aliases ).
197
204
205
+ ## ` mergeConfig `
206
+
207
+ ** Type Signature :**
208
+
209
+ ` ` ` ts
210
+ function mergeConfig(
211
+ defaults: Record<string, any>,
212
+ overrides: Record<string, any>,
213
+ isRoot = true
214
+ ): Record<string, any>
215
+ ` ` `
216
+
217
+ Deeply merge two Vite configs . ` isRoot ` represents the level within the Vite config which is being merged . For example , set ` false ` if you ' re merging two `build` options.
218
+
219
+ ## ` searchForWorkspaceRoot `
220
+
221
+ ** Type Signature :**
222
+
223
+ ` ` ` ts
224
+ function searchForWorkspaceRoot(
225
+ current: string,
226
+ root = searchForPackageRoot(current)
227
+ ): string
228
+ ` ` `
229
+
230
+ ** Related :** [server .fs .allow ](/ config / server - options .md #server - fs - allow )
231
+
232
+ Search for the root of the potential workspace if it meets the following conditions , otherwise it would fallback to ` root ` :
233
+
234
+ - contains ` workspaces ` field in ` package.json `
235
+ - contains one of the following file
236
+ - ` lerna.json `
237
+ - ` pnpm-workspace.yaml `
238
+
239
+ ## ` loadEnv `
240
+
241
+ ** Type Signature :**
242
+
243
+ ` ` ` ts
244
+ function loadEnv(
245
+ mode: string,
246
+ envDir: string,
247
+ prefixes: string | string[] = 'VITE_'
248
+ ): Record<string, string>
249
+ ` ` `
250
+
251
+ ** Related :** [` .env ` Files ](./ env - and - mode .md #env - files )
252
+
253
+ Load ` .env ` files within the ` envDir ` . By default only env variables prefixed with ` VITE_ ` are loaded , unless ` prefixes ` is changed .
254
+
255
+ ## ` normalizePath `
256
+
257
+ ** Type Signature :**
258
+
259
+ ` ` ` ts
260
+ function normalizePath(id: string): string
261
+ ` ` `
262
+
263
+ ** Related :** [Path Normalization ](./ api - plugin .md #path - normalization )
264
+
265
+ Normalizes a path to interoperate between Vite plugins .
266
+
198
267
## ` transformWithEsbuild `
199
268
200
269
** Type Signature :**
@@ -207,3 +276,24 @@ async function transformWithEsbuild(
207
276
inMap?: object
208
277
): Promise<ESBuildTransformResult>
209
278
` ` `
279
+
280
+ Transform JavaScript or TypeScript with esbuild . Useful for plugins that prefers matching Vite ' s internal esbuild transform.
281
+
282
+ ## ` loadConfigFromFile `
283
+
284
+ ** Type Signature :**
285
+
286
+ ` ` ` ts
287
+ async function loadConfigFromFile(
288
+ configEnv: ConfigEnv,
289
+ configFile?: string,
290
+ configRoot: string = process.cwd(),
291
+ logLevel?: LogLevel
292
+ ): Promise<{
293
+ path: string
294
+ config: UserConfig
295
+ dependencies: string[]
296
+ } | null>
297
+ ` ` `
298
+
299
+ Load a Vite config file manually with esbuild .
0 commit comments