mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 14:41:25 +00:00
feat(docs): loadNuxt utility
This commit is contained in:
parent
483dbc6b64
commit
06d00014d3
@ -74,9 +74,76 @@ export default defineNuxtModule<ModuleOptions>({
|
||||
|
||||
[source code](https://github.com/nuxt/nuxt/blob/main/packages/kit/src/loader)
|
||||
|
||||
- `loadNuxt(loadOptions)`
|
||||
- `buildNuxt(nuxt)`
|
||||
- `loadNuxtConfig(loadOptions)`
|
||||
Programmatic usage can be helpfull when you want to use Nuxt programmatically, for example, when building a CLI tool or test runner.
|
||||
|
||||
### `loadNuxt`
|
||||
|
||||
Load Nuxt programmatically
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
async function loadNuxt (loadOptions?: LoadNuxtOptions): Promise<Nuxt>
|
||||
|
||||
interface LoadNuxtOptions extends LoadNuxtConfigOptions {
|
||||
dev?: boolean
|
||||
ready?: boolean
|
||||
rootDir?: string
|
||||
config?: LoadNuxtConfigOptions['overrides']
|
||||
}
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
loadNuxt uses [`c12`](https://github.com/unjs/c12/tree/main) under the hood, so it accepts the same options as `c12` with some additional options:
|
||||
|
||||
##### `loadOptions`
|
||||
|
||||
**Type**: `LoadNuxtOptions`
|
||||
|
||||
**Default**: `{}`
|
||||
|
||||
An object with the following properties:
|
||||
|
||||
- `dev` (optional)
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Default**: `false`
|
||||
|
||||
If set to `true`, Nuxt will be loaded in development mode.
|
||||
|
||||
- `ready` (optional)
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Default**: `true`
|
||||
|
||||
If set to `true`, Nuxt will be ready to use after the `loadNuxt` call. If set to `false`, you will need to call `nuxt.ready()` to make sure Nuxt is ready to use.
|
||||
|
||||
- `rootDir` (optional)
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Default**: `null`
|
||||
|
||||
**Deprecated**: Use `cwd` option instead.
|
||||
|
||||
The root directory of the Nuxt project.
|
||||
|
||||
- `config` (optional)
|
||||
|
||||
**Type**: `LoadNuxtConfigOptions['overrides']`
|
||||
|
||||
**Default**: `{}`
|
||||
|
||||
**Deprecated**: Use `overrides` option instead.
|
||||
|
||||
Overrides for the Nuxt configuration.
|
||||
|
||||
### `buildNuxt(nuxt)`
|
||||
|
||||
### `loadNuxtConfig(loadOptions)`
|
||||
|
||||
## Compatibility
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user