@nuxt/docs-nightly 5.0.0-29802883.a46ecec7 → 5.0.0-29803262.c057c9fb
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.
|
@@ -219,6 +219,28 @@ For a custom builder you only need to satisfy the generic contract. The Vite Env
|
|
|
219
219
|
|
|
220
220
|
Which of the two paths is in use is decided by the *server* builder, not by the flag directly: a server builder declares whether its build is a pass of its own, run after the app build, or an environment of the app builder's build. `@nuxt/nitro-server` declares it from `experimental.nitroViteEnvironment`, and a server builder with no build pass of its own (such as `@nuxt/vite-server`) declares that Vite is building everything.
|
|
221
221
|
|
|
222
|
+
## Describing the Build to a Deploy Target
|
|
223
|
+
|
|
224
|
+
A server builder describes what it produced, so that tooling that deploys or previews the build does not have to know which builder ran. The description lives on `nuxt.serverBuild`, and is read with `useServerBuild()` from `@nuxt/kit/internal`:
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { useServerBuild } from '@nuxt/kit/internal'
|
|
228
|
+
|
|
229
|
+
const build = useServerBuild()
|
|
230
|
+
|
|
231
|
+
build.output.root() // the project root: where a target's own config file lives
|
|
232
|
+
build.output.dir() // the build output directory
|
|
233
|
+
build.output.publicDir() // the deployable static assets within it
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Every path is a function, because a builder may only resolve it while initialising, so call them from a hook that runs after the server builder has run.
|
|
237
|
+
|
|
238
|
+
`output.root()` is deliberately not a bundler root. Nuxt points Vite's `root` at [`srcDir`](/docs/4.x/api/nuxt-config#srcdir), so a deploy target that resolves its configuration file (or the paths written inside it) from the bundler's root looks inside your app directory rather than at the root of your project. A target that reads the description resolves both correctly.
|
|
239
|
+
|
|
240
|
+
::warning
|
|
241
|
+
`nuxt.serverBuild` and the `setServerBuild()` / `useServerBuild()` helpers are experimental and exported from `@nuxt/kit/internal`. The shape will change without a major release while a second server builder is being built out.
|
|
242
|
+
::
|
|
243
|
+
|
|
222
244
|
::read-more{to="/docs/4.x/guide/going-further/internals"}
|
|
223
245
|
Learn more about the Nuxt interface and the build vs. runtime split.
|
|
224
246
|
::
|