@nuxt/docs-nightly 4.2.0-29334960.22f4693a → 4.2.0-29335187.d989fb8b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,11 +59,6 @@ export default defineNuxtConfig({
|
|
|
59
59
|
|
|
60
60
|
There is also a `future` namespace for early opting-in to new features that will become default in a future (possibly major) version of the framework.
|
|
61
61
|
|
|
62
|
-
### compatibilityVersion
|
|
63
|
-
|
|
64
|
-
This is used for enabling early access to Nuxt features or flags.
|
|
65
|
-
|
|
66
|
-
|
|
67
62
|
### compatibilityVersion
|
|
68
63
|
|
|
69
64
|
This enables early access to Nuxt features or flags.
|
|
@@ -63,3 +63,26 @@ import config from '~/data/hello.yaml'
|
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
::
|
|
66
|
+
|
|
67
|
+
## Using Vite Plugins in Nuxt Modules
|
|
68
|
+
|
|
69
|
+
If you're developing a Nuxt module and need to add Vite plugins, you should use the [`addVitePlugin`](/docs/4.x/api/kit/builder#addviteplugin) utility:
|
|
70
|
+
|
|
71
|
+
```ts [modules/my-module.ts]
|
|
72
|
+
import { addVitePlugin, defineNuxtModule } from '@nuxt/kit'
|
|
73
|
+
import yaml from '@rollup/plugin-yaml'
|
|
74
|
+
|
|
75
|
+
export default defineNuxtModule({
|
|
76
|
+
setup () {
|
|
77
|
+
addVitePlugin(yaml())
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
::important
|
|
83
|
+
If you're writing code that needs to access resolved Vite configuration, you should use the `config` and `configResolved` hooks _within_ your Vite plugin, rather than using Nuxt's `vite:extend`, `vite:extendConfig` and `vite:configResolved`.
|
|
84
|
+
::
|
|
85
|
+
|
|
86
|
+
::read-more{to="/docs/4.x/api/kit/builder#addviteplugin"}
|
|
87
|
+
Read more about `addVitePlugin` in the Nuxt Kit documentation.
|
|
88
|
+
::
|
|
@@ -14,6 +14,10 @@ Nuxt have builders based on [Vite](https://github.com/nuxt/nuxt/tree/main/packag
|
|
|
14
14
|
|
|
15
15
|
Extends the Vite configuration. Callback function can be called multiple times, when applying to both client and server builds.
|
|
16
16
|
|
|
17
|
+
::warning
|
|
18
|
+
This hook is now deprecated, and we recommend using a Vite plugin instead with a `config` hook.
|
|
19
|
+
::
|
|
20
|
+
|
|
17
21
|
### Usage
|
|
18
22
|
|
|
19
23
|
```ts twoslash
|
|
@@ -22,11 +22,9 @@ import { buildNuxt, loadNuxt } from '@nuxt/kit'
|
|
|
22
22
|
async function getViteConfig () {
|
|
23
23
|
const nuxt = await loadNuxt({ cwd: process.cwd(), dev: false, overrides: { ssr: false } })
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
|
-
nuxt.hook('vite:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw new Error('_stop_')
|
|
29
|
-
}
|
|
25
|
+
nuxt.hook('vite:extend', (config) => {
|
|
26
|
+
resolve(config)
|
|
27
|
+
throw new Error('_stop_')
|
|
30
28
|
})
|
|
31
29
|
buildNuxt(nuxt).catch((err) => {
|
|
32
30
|
if (!err.toString().includes('_stop_')) {
|
|
@@ -75,8 +75,8 @@ Hook | Arguments | Description
|
|
|
75
75
|
`schema:beforeWrite` | `schema` | Called before writing the given schema.
|
|
76
76
|
`schema:written` | - | Called after the schema is written.
|
|
77
77
|
`vite:extend` | `viteBuildContext` | Allows extending Vite default context.
|
|
78
|
-
`vite:extendConfig` | `viteInlineConfig, env` | Allows extending Vite default config.
|
|
79
|
-
`vite:configResolved` | `viteInlineConfig, env` | Allows reading the resolved Vite config.
|
|
78
|
+
`vite:extendConfig` | `viteInlineConfig, env` | Allows extending Vite default config. **Deprecated.** We recommend adding a Vite plugin with a `config` hook.
|
|
79
|
+
`vite:configResolved` | `viteInlineConfig, env` | Allows reading the resolved Vite config. **Deprecated.** We recommend adding a Vite plugin with a `configResolved` hook.
|
|
80
80
|
`vite:serverCreated` | `viteServer, env` | Called when the Vite server is created.
|
|
81
81
|
`vite:compiled` | - | Called after Vite server is compiled.
|
|
82
82
|
`webpack:config` | `webpackConfigs` | Called before configuring the webpack compiler.
|