@nuxt/docs-nightly 5.0.0-2611041650-9fa3713 → 5.0.0-2611042158-c8d0ca8
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.
- package/1.getting-started/01.introduction.md +1 -1
- package/1.getting-started/18.upgrade.md +79 -0
- package/3.guide/6.going-further/1.experimental-features.md +2 -2
- package/4.api/5.kit/15.builder.md +108 -4
- package/4.api/5.kit/3.compatibility.md +1 -1
- package/4.api/6.advanced/1.hooks.md +3 -0
- package/4.api/6.nuxt-config.md +47 -5
- package/5.community/5.framework-contribution.md +2 -1
- package/package.json +1 -1
|
@@ -73,7 +73,7 @@ A module system allows you to extend Nuxt with custom features and integrations
|
|
|
73
73
|
Nuxt is composed of different [core packages](https://github.com/nuxt/nuxt/tree/main/packages):
|
|
74
74
|
|
|
75
75
|
- Core engine: [nuxt](https://github.com/nuxt/nuxt/tree/main/packages/nuxt)
|
|
76
|
-
- Bundlers: [@nuxt/vite-builder](https://github.com/nuxt/nuxt/tree/main/packages/vite), [@nuxt/
|
|
76
|
+
- Bundlers: [@nuxt/vite-builder](https://github.com/nuxt/nuxt/tree/main/packages/vite), [@nuxt/rsbuild-builder](https://github.com/nuxt/nuxt/tree/main/packages/rsbuild) and [@nuxt/webpack-builder](https://github.com/nuxt/nuxt/tree/main/packages/webpack)
|
|
77
77
|
- Command line interface: [@nuxt/cli](https://github.com/nuxt/cli)
|
|
78
78
|
- Server engine: [nitro](https://github.com/nitrojs/nitro)
|
|
79
79
|
- Development kit: [@nuxt/kit](https://github.com/nuxt/nuxt/tree/main/packages/kit)
|
|
@@ -53,6 +53,7 @@ The changes are:
|
|
|
53
53
|
- **Vite Environment API**: Vite plugins are [registered and configured per environment](/docs/getting-started/upgrade#migration-to-vite-environment-api)
|
|
54
54
|
- **Vite 8**: The bundler is [Rolldown rather than esbuild and Rollup](/docs/getting-started/upgrade#migration-to-vite-8)
|
|
55
55
|
- **Nitro as a Vite environment**: With `@nuxt/vite-builder`, server and client are [built by one Vite build](/docs/getting-started/upgrade#nitro-builds-as-a-vite-environment)
|
|
56
|
+
- **Rsbuild builder**: `@nuxt/rspack-builder` is deprecated in favour of [`@nuxt/rsbuild-builder`](/docs/getting-started/upgrade#rspack-builder-is-replaced-by-the-rsbuild-builder)
|
|
56
57
|
- **Typed `$fetch`**: `$fetch` and `useFetch` are typed from [generated route types](/docs/getting-started/upgrade#typed-fetch-rebuilt-on-generated-route-types) rather than nitro's `InternalApi`
|
|
57
58
|
- **No client `globalThis.$fetch`**: In the browser, `$fetch` is [an import rather than a global](/docs/getting-started/upgrade#fetch-is-no-longer-a-global-in-the-browser)
|
|
58
59
|
- **`jiti` is no longer bundled**: `nuxt.config`, `modules/` and layer configs are [loaded by the runtime](/docs/getting-started/upgrade#jiti-is-no-longer-bundled)
|
|
@@ -554,6 +555,84 @@ export default defineNuxtConfig({
|
|
|
554
555
|
})
|
|
555
556
|
```
|
|
556
557
|
|
|
558
|
+
### Rspack Builder Is Replaced by the Rsbuild Builder
|
|
559
|
+
|
|
560
|
+
🚦 **Impact Level**: Medium (only if you use `builder: 'rspack'`)
|
|
561
|
+
|
|
562
|
+
#### What Changed
|
|
563
|
+
|
|
564
|
+
Nuxt has a new builder, `@nuxt/rsbuild-builder`, enabled with `builder: 'rsbuild'`. It builds your app with [Rsbuild](https://rsbuild.rs), which runs on Rspack, and is configured with the new [`rsbuild`](/docs/api/nuxt-config#rsbuild) option.
|
|
565
|
+
|
|
566
|
+
`@nuxt/rspack-builder` is deprecated and logs a warning. It still works in Nuxt 5 and will be removed in a future major version.
|
|
567
|
+
|
|
568
|
+
#### Reasons for Change
|
|
569
|
+
|
|
570
|
+
`@nuxt/rspack-builder` generates its Rspack configuration from the webpack builder's presets, with loaders for CSS, PostCSS, esbuild and assets. `@nuxt/rsbuild-builder` uses Rsbuild's own handling of these instead (SWC for scripts, Lightning CSS for styles), with the Rsbuild plugin ecosystem.
|
|
571
|
+
|
|
572
|
+
#### Migration Steps
|
|
573
|
+
|
|
574
|
+
Replace `@nuxt/rspack-builder` with `@nuxt/rsbuild-builder`:
|
|
575
|
+
|
|
576
|
+
::code-group{sync="pm"}
|
|
577
|
+
|
|
578
|
+
```bash [npm]
|
|
579
|
+
npm uninstall @nuxt/rspack-builder
|
|
580
|
+
npm install -D @nuxt/rsbuild-builder
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
```bash [yarn]
|
|
584
|
+
yarn remove @nuxt/rspack-builder
|
|
585
|
+
yarn add -D @nuxt/rsbuild-builder
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
```bash [pnpm]
|
|
589
|
+
pnpm remove @nuxt/rspack-builder
|
|
590
|
+
pnpm add -D @nuxt/rsbuild-builder
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
```bash [bun]
|
|
594
|
+
bun remove @nuxt/rspack-builder
|
|
595
|
+
bun add -D @nuxt/rsbuild-builder
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
::
|
|
599
|
+
|
|
600
|
+
Then update the builder in your `nuxt.config`:
|
|
601
|
+
|
|
602
|
+
```diff
|
|
603
|
+
export default defineNuxtConfig({
|
|
604
|
+
- builder: 'rspack',
|
|
605
|
+
+ builder: 'rsbuild',
|
|
606
|
+
})
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
The Rsbuild builder does not read the `webpack` options, so move any you set to the `rsbuild` option. For example, `webpack.loaders.vue` becomes `rsbuild.vue.vueLoaderOptions`, and options for one build go under `rsbuild.environments.client` or `rsbuild.environments.ssr`. PostCSS plugins are still configured with `postcss.plugins`, and `build.analyze` writes an [Rsdoctor](https://rsdoctor.rs) report.
|
|
610
|
+
|
|
611
|
+
Install the Rsbuild plugin for each language you use instead of its webpack loader. Nuxt registers these plugins when they are installed, and warns when a file needs one that is missing.
|
|
612
|
+
|
|
613
|
+
| Language | webpack loader | Rsbuild plugin |
|
|
614
|
+
| --------- | ------------------ | ------------------------ |
|
|
615
|
+
| Sass/SCSS | `sass-loader` | `@rsbuild/plugin-sass` |
|
|
616
|
+
| Less | `less-loader` | `@rsbuild/plugin-less` |
|
|
617
|
+
| Stylus | `stylus-loader` | `@rsbuild/plugin-stylus` |
|
|
618
|
+
| Pug | `pug-plain-loader` | `@rsbuild/plugin-pug` |
|
|
619
|
+
|
|
620
|
+
Type checking with `typescript.typeCheck` uses `@rsbuild/plugin-type-check`, which Nuxt offers to install when it is missing.
|
|
621
|
+
|
|
622
|
+
#### For Module Authors
|
|
623
|
+
|
|
624
|
+
- `addRspackPlugin()`, `extendRspackConfig()` and `addBuildPlugin()` with an `rspack` plugin keep working, and the `rspack:config` and `rspack:configResolved` hooks are still called. The Rspack configurations are generated by Rsbuild, so their `module.rules` differ from the ones of `@nuxt/rspack-builder`. To change how files are processed, use [`extendRsbuildConfig()`](/docs/api/kit/builder#extendrsbuildconfig) or [`addRsbuildPlugin()`](/docs/api/kit/builder#addrsbuildplugin).
|
|
625
|
+
- The server build is named `ssr` rather than `server`. Code that looks up the server configuration in `rspack:config` needs to check for both:
|
|
626
|
+
|
|
627
|
+
```diff
|
|
628
|
+
nuxt.hook('rspack:config', (configs) => {
|
|
629
|
+
- const server = configs.find(config => config.name === 'server')
|
|
630
|
+
+ const server = configs.find(config => config.name === 'server' || config.name === 'ssr')
|
|
631
|
+
})
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
- The `rspack:compile` and `rspack:compiled` hooks are not called. Use `rsbuild:compile` and `rsbuild:compiled`, which receive the environment `name`, its Rspack `compiler` and, once compiled, its `stats`.
|
|
635
|
+
|
|
557
636
|
### Server Imports Move to `nuxt/server`
|
|
558
637
|
|
|
559
638
|
🚦 **Impact Level**: Medium
|
|
@@ -528,7 +528,7 @@ You can also set this to `chokidar` to watch all files in your source directory.
|
|
|
528
528
|
Set to `'builder'` to reuse the active builder's own file watcher (for example,
|
|
529
529
|
Vite's `server.watcher`) instead of starting a second one. This reduces the
|
|
530
530
|
number of file watchers active in dev mode and is the default. If the active builder does not implement
|
|
531
|
-
its own watcher (currently webpack and rspack), Nuxt logs a warning and falls
|
|
531
|
+
its own watcher (currently webpack, Rsbuild and rspack), Nuxt logs a warning and falls
|
|
532
532
|
back to its default selection.
|
|
533
533
|
|
|
534
534
|
```ts twoslash [nuxt.config.ts]
|
|
@@ -990,7 +990,7 @@ export default defineNuxtConfig({
|
|
|
990
990
|
|
|
991
991
|
This option enables decorator syntax across your entire Nuxt/Nitro app.
|
|
992
992
|
|
|
993
|
-
When using the Vite builder (default), decorators are lowered via [Babel](https://babeljs.io/) using [`@babel/plugin-proposal-decorators`](https://babeljs.io/docs/babel-plugin-proposal-decorators). When using the webpack or rspack builders, decorators are lowered via [esbuild](https://github.com/evanw/esbuild/releases/tag/v0.21.3).
|
|
993
|
+
When using the Vite builder (default), decorators are lowered via [Babel](https://babeljs.io/) using [`@babel/plugin-proposal-decorators`](https://babeljs.io/docs/babel-plugin-proposal-decorators). When using the webpack or rspack builders, decorators are lowered via [esbuild](https://github.com/evanw/esbuild/releases/tag/v0.21.3). When using the Rsbuild builder, decorators are lowered via [SWC](https://rsbuild.rs/config/source/decorators).
|
|
994
994
|
|
|
995
995
|
For a long time, TypeScript has had support for decorators via `compilerOptions.experimentalDecorators`. This implementation predated the TC39 standardization process. Now, decorators are a [Stage 3 Proposal](https://github.com/tc39/proposal-decorators), and supported without special configuration in TS 5.0+ (see https://github.com/microsoft/TypeScript/pull/52582 and https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#decorators).
|
|
996
996
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Builder
|
|
3
|
-
description: Nuxt Kit provides a set of utilities to help you work with the builder. These functions allow you to extend the Vite and
|
|
3
|
+
description: Nuxt Kit provides a set of utilities to help you work with the builder. These functions allow you to extend the Vite, webpack and Rsbuild configurations.
|
|
4
4
|
links:
|
|
5
5
|
- label: Source
|
|
6
6
|
icon: i-simple-icons-github
|
|
@@ -8,7 +8,7 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
Nuxt have builders based on [Vite](https://github.com/nuxt/nuxt/tree/main/packages/vite)
|
|
11
|
+
Nuxt have builders based on [Vite](https://github.com/nuxt/nuxt/tree/main/packages/vite), [webpack](https://github.com/nuxt/nuxt/tree/main/packages/webpack) and [Rsbuild](https://github.com/nuxt/nuxt/tree/main/packages/rsbuild). You can extend the config passed to each one using `extendViteConfig`, `extendWebpackConfig` and `extendRsbuildConfig` functions. You can also add additional plugins via `addVitePlugin`, `addWebpackPlugin`, `addRsbuildPlugin` and `addBuildPlugin`.
|
|
12
12
|
|
|
13
13
|
## `extendViteConfig`
|
|
14
14
|
|
|
@@ -150,6 +150,53 @@ Check out webpack website for more information about its configuration.
|
|
|
150
150
|
| `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle. |
|
|
151
151
|
| `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
|
|
152
152
|
|
|
153
|
+
## `extendRsbuildConfig`
|
|
154
|
+
|
|
155
|
+
Extends the Rsbuild configuration. The callback function is called once, with a configuration containing both the `client` and `ssr` environments.
|
|
156
|
+
|
|
157
|
+
### Usage
|
|
158
|
+
|
|
159
|
+
```ts twoslash
|
|
160
|
+
import { defineNuxtModule, extendRsbuildConfig } from '@nuxt/kit'
|
|
161
|
+
|
|
162
|
+
export default defineNuxtModule({
|
|
163
|
+
setup () {
|
|
164
|
+
extendRsbuildConfig((config) => {
|
|
165
|
+
config.environments ||= {}
|
|
166
|
+
config.environments.client ||= {}
|
|
167
|
+
config.environments.client.performance = {
|
|
168
|
+
removeConsole: ['log'],
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
},
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Type
|
|
176
|
+
|
|
177
|
+
```ts twoslash
|
|
178
|
+
// @errors: 2391
|
|
179
|
+
import type { RsbuildConfig } from '@rsbuild/core'
|
|
180
|
+
import type { ExtendRsbuildConfigOptions } from '@nuxt/kit'
|
|
181
|
+
// ---cut---
|
|
182
|
+
function extendRsbuildConfig (callback: ((config: RsbuildConfig) => void), options?: ExtendRsbuildConfigOptions): void
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
::read-more{to="https://rsbuild.rs/config/" target="_blank"}
|
|
186
|
+
Check out Rsbuild website for more information about its configuration.
|
|
187
|
+
::
|
|
188
|
+
|
|
189
|
+
### Parameters
|
|
190
|
+
|
|
191
|
+
**`callback`**: A callback function that will be called with the Rsbuild configuration object.
|
|
192
|
+
|
|
193
|
+
**`options`**: Options to pass to the callback function. This object can have the following properties:
|
|
194
|
+
|
|
195
|
+
| Property | Type | Required | Description |
|
|
196
|
+
|----------|-----------|----------|-------------------------------------------------------------------------------------------|
|
|
197
|
+
| `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
|
|
198
|
+
| `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
|
|
199
|
+
|
|
153
200
|
## `addVitePlugin`
|
|
154
201
|
|
|
155
202
|
Append Vite plugin to the config.
|
|
@@ -294,9 +341,64 @@ See [webpack website](https://webpack.js.org/concepts/plugins/) for more informa
|
|
|
294
341
|
| `client` | `boolean` | `false` | If set to `true`, the callback function will be called when building the client bundle. |
|
|
295
342
|
| `prepend` | `boolean` | `false` | If set to `true`, the callback function will be prepended to the array with `unshift()` instead of `push()`. |
|
|
296
343
|
|
|
344
|
+
## `addRsbuildPlugin`
|
|
345
|
+
|
|
346
|
+
Append Rsbuild plugin to the config.
|
|
347
|
+
|
|
348
|
+
### Usage
|
|
349
|
+
|
|
350
|
+
```ts twoslash
|
|
351
|
+
import { addRsbuildPlugin, defineNuxtModule } from '@nuxt/kit'
|
|
352
|
+
|
|
353
|
+
export default defineNuxtModule({
|
|
354
|
+
setup () {
|
|
355
|
+
addRsbuildPlugin({
|
|
356
|
+
name: 'my-rsbuild-plugin',
|
|
357
|
+
setup (api) {
|
|
358
|
+
api.onAfterBuild(() => {
|
|
359
|
+
console.log('The client and server builds are complete')
|
|
360
|
+
})
|
|
361
|
+
},
|
|
362
|
+
})
|
|
363
|
+
},
|
|
364
|
+
})
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Type
|
|
368
|
+
|
|
369
|
+
```ts twoslash
|
|
370
|
+
// @errors: 2391
|
|
371
|
+
import type { RsbuildPlugin } from '@rsbuild/core'
|
|
372
|
+
import type { ExtendConfigOptions } from '@nuxt/kit'
|
|
373
|
+
// ---cut---
|
|
374
|
+
function addRsbuildPlugin (pluginOrGetter: RsbuildPlugin | RsbuildPlugin[] | (() => RsbuildPlugin | RsbuildPlugin[]), options?: ExtendConfigOptions): void
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
::tip
|
|
378
|
+
See [Rsbuild website](https://rsbuild.rs/plugins/dev/) for more information about Rsbuild plugins. When `client` or `server` is set to `false`, the plugin is only registered for the other [environment](https://rsbuild.rs/config/environments).
|
|
379
|
+
::
|
|
380
|
+
|
|
381
|
+
### Parameters
|
|
382
|
+
|
|
383
|
+
**`pluginOrGetter`**: An Rsbuild plugin or an array of Rsbuild plugins. If a function is provided, it must return an Rsbuild plugin or an array of Rsbuild plugins. The function can also be async or return a Promise, enabling lazy-loading of plugins.
|
|
384
|
+
|
|
385
|
+
**`options`**: Options to pass to the callback function. This object can have the following properties:
|
|
386
|
+
|
|
387
|
+
| Property | Type | Required | Description |
|
|
388
|
+
|-----------|-----------|----------|--------------------------------------------------------------------------------------------------------------|
|
|
389
|
+
| `dev` | `boolean` | `false` | If set to `true`, the callback function will be called when building in development mode. |
|
|
390
|
+
| `build` | `boolean` | `false` | If set to `true`, the callback function will be called when building in production mode. |
|
|
391
|
+
| `server` | `boolean` | `false` | If set to `true`, the plugin will be registered for the server environment. |
|
|
392
|
+
| `client` | `boolean` | `false` | If set to `true`, the plugin will be registered for the client environment. |
|
|
393
|
+
| `prepend` | `boolean` | `false` | If set to `true`, the plugin will be prepended to the array with `unshift()` instead of `push()`. |
|
|
394
|
+
|
|
297
395
|
## `addBuildPlugin`
|
|
298
396
|
|
|
299
|
-
Builder-agnostic version of `addVitePlugin` and `
|
|
397
|
+
Builder-agnostic version of `addVitePlugin`, `addWebpackPlugin` and `addRsbuildPlugin`. It will add the plugin to the Vite, webpack and Rsbuild configurations if they are present.
|
|
398
|
+
|
|
399
|
+
::note
|
|
400
|
+
The Rsbuild builder is based on Rspack and applies the `rspack` plugin when one is provided, so plugins run in the order they are added. The `rsbuild` plugin is only used when there is no `rspack` plugin.
|
|
401
|
+
::
|
|
300
402
|
|
|
301
403
|
### Type
|
|
302
404
|
|
|
@@ -306,10 +408,12 @@ import type { ExtendConfigOptions } from '@nuxt/kit'
|
|
|
306
408
|
import type { Plugin as VitePlugin } from 'vite'
|
|
307
409
|
import type { WebpackPluginInstance } from 'webpack'
|
|
308
410
|
import type { RspackPluginInstance } from '@rspack/core'
|
|
411
|
+
import type { RsbuildPlugin } from '@rsbuild/core'
|
|
309
412
|
|
|
310
413
|
interface AddBuildPluginFactory {
|
|
311
414
|
vite?: () => VitePlugin | VitePlugin[]
|
|
312
415
|
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[]
|
|
416
|
+
rsbuild?: () => RsbuildPlugin | RsbuildPlugin[]
|
|
313
417
|
rspack?: () => RspackPluginInstance | RspackPluginInstance[]
|
|
314
418
|
}
|
|
315
419
|
// ---cut---
|
|
@@ -318,7 +422,7 @@ function addBuildPlugin (pluginFactory: AddBuildPluginFactory, options?: ExtendC
|
|
|
318
422
|
|
|
319
423
|
### Parameters
|
|
320
424
|
|
|
321
|
-
**`pluginFactory`**: A factory function that returns an object with `vite` and/or `
|
|
425
|
+
**`pluginFactory`**: A factory function that returns an object with `vite`, `webpack`, `rsbuild` and/or `rspack` properties. These properties must be functions that return a plugin instance or an array of plugin instances for the corresponding builder.
|
|
322
426
|
|
|
323
427
|
**`options`**: Options to pass to the callback function. This object can have the following properties:
|
|
324
428
|
|
|
@@ -44,7 +44,7 @@ function checkNuxtCompatibility (constraints: NuxtCompatibility, nuxt?: Nuxt): P
|
|
|
44
44
|
| Property | Type | Required | Description |
|
|
45
45
|
| -------- | --------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
46
46
|
| `nuxt` | `string` | `false` | Nuxt version in semver format. Versions may be defined in Node.js way, for example: `>=2.15.0 <3.0.0`. |
|
|
47
|
-
| `bridge` | `Record<string, string \| false>`{lang="ts"} | `false` | Specifies version constraints or disables compatibility for specific Nuxt builders like `vite`, `webpack`, or `rspack`. Use `false` to disable.
|
|
47
|
+
| `bridge` | `Record<string, string \| false>`{lang="ts"} | `false` | Specifies version constraints or disables compatibility for specific Nuxt builders like `vite`, `webpack`, `rsbuild`, or `rspack`. Use `false` to disable. |
|
|
48
48
|
|
|
49
49
|
**`nuxt`**: Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
|
50
50
|
|
|
@@ -90,6 +90,9 @@ Check the [schema source code](https://github.com/nuxt/nuxt/blob/main/packages/s
|
|
|
90
90
|
| `webpack:error` | - | Called on `done` if has errors on WebpackBar. |
|
|
91
91
|
| `webpack:done` | - | Called on `allDone` on WebpackBar. |
|
|
92
92
|
| `webpack:progress` | `statesArray` | Called on `progress` on WebpackBar. |
|
|
93
|
+
| `rsbuild:config` | `rsbuildConfig` | Called before creating the Rsbuild instance, with the Rsbuild config containing the `client` and `ssr` environments. The Rsbuild builder also calls `rspack:config` and `rspack:configResolved` with the generated Rspack configs, named `client` and `ssr`. |
|
|
94
|
+
| `rsbuild:compile` | `options` | Called right before the first compilation of an environment. |
|
|
95
|
+
| `rsbuild:compiled` | `options` | Called after an environment has been compiled. |
|
|
93
96
|
|
|
94
97
|
## Nitro App Hooks (Runtime, Server-Side)
|
|
95
98
|
|
package/4.api/6.nuxt-config.md
CHANGED
|
@@ -362,6 +362,8 @@ Nuxt allows visualizing your bundles and how to optimize them.
|
|
|
362
362
|
|
|
363
363
|
Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack/webpack-bundle-analyzer#options-for-plugin) or [for vite](https://github.com/btd/rollup-plugin-visualizer#options).
|
|
364
364
|
|
|
365
|
+
With the Rsbuild builder, Nuxt writes an [Rsdoctor](https://rsdoctor.rs) report to `filename` unless `enabled` is `false`, and ignores the other options.
|
|
366
|
+
|
|
365
367
|
- **Type**: `object`
|
|
366
368
|
- **Default**
|
|
367
369
|
```json
|
|
@@ -445,9 +447,9 @@ A unique identifier matching the build. This may contain the hash of the current
|
|
|
445
447
|
|
|
446
448
|
The builder to use for bundling the Vue part of your application.
|
|
447
449
|
|
|
448
|
-
Nuxt supports multiple builders for the client-side application. By default, Vite is used, but you can switch to webpack,
|
|
450
|
+
Nuxt supports multiple builders for the client-side application. By default, Vite is used, but you can switch to webpack, Rsbuild, or even provide a custom builder implementation.
|
|
449
451
|
|
|
450
|
-
- **Type**: `'vite' | 'webpack' | 'rspack' | string | { bundle: (nuxt: Nuxt) => Promise<void> }`
|
|
452
|
+
- **Type**: `'vite' | 'webpack' | 'rsbuild' | 'rspack' | string | { bundle: (nuxt: Nuxt) => Promise<void> }`
|
|
451
453
|
- **Default:** `"@nuxt/vite-builder"`
|
|
452
454
|
|
|
453
455
|
**Using supported builders:**
|
|
@@ -460,12 +462,16 @@ export default defineNuxtConfig({
|
|
|
460
462
|
// uses @nuxt/webpack-builder
|
|
461
463
|
// builder: 'webpack',
|
|
462
464
|
|
|
463
|
-
// uses @nuxt/
|
|
464
|
-
builder: '
|
|
465
|
+
// uses @nuxt/rsbuild-builder
|
|
466
|
+
builder: 'rsbuild',
|
|
465
467
|
})
|
|
466
468
|
```
|
|
467
469
|
|
|
468
|
-
If you are using `webpack` or `
|
|
470
|
+
If you are using `webpack` or `rsbuild` you will need to make sure `@nuxt/webpack-builder` or `@nuxt/rsbuild-builder` is explicitly installed in your project.
|
|
471
|
+
|
|
472
|
+
::warning
|
|
473
|
+
The Rspack builder (`builder: 'rspack'`, using `@nuxt/rspack-builder`) is deprecated in favour of the Rsbuild builder, which is built on top of Rspack. See the [upgrade guide](/docs/getting-started/upgrade#rspack-builder-is-replaced-by-the-rsbuild-builder) for how to migrate.
|
|
474
|
+
::
|
|
469
475
|
|
|
470
476
|
**Using a custom builder object:**
|
|
471
477
|
|
|
@@ -1270,6 +1276,42 @@ Customize the scroll behavior for hash links.
|
|
|
1270
1276
|
|
|
1271
1277
|
**Default**: 'auto'
|
|
1272
1278
|
|
|
1279
|
+
## rsbuild
|
|
1280
|
+
|
|
1281
|
+
Configuration that will be merged into the Rsbuild configuration generated by Nuxt, when using the Rsbuild builder (`builder: 'rsbuild'`).
|
|
1282
|
+
|
|
1283
|
+
Top-level options are shared by the client and server builds. Use `environments.client` and `environments.ssr` to provide configuration for each build.
|
|
1284
|
+
|
|
1285
|
+
**Example**:
|
|
1286
|
+
```ts
|
|
1287
|
+
export default defineNuxtConfig({
|
|
1288
|
+
builder: 'rsbuild',
|
|
1289
|
+
rsbuild: {
|
|
1290
|
+
output: {
|
|
1291
|
+
dataUriLimit: 8192,
|
|
1292
|
+
},
|
|
1293
|
+
environments: {
|
|
1294
|
+
client: {
|
|
1295
|
+
performance: {
|
|
1296
|
+
removeConsole: ['log'],
|
|
1297
|
+
},
|
|
1298
|
+
},
|
|
1299
|
+
},
|
|
1300
|
+
},
|
|
1301
|
+
})
|
|
1302
|
+
```
|
|
1303
|
+
|
|
1304
|
+
**See**: [Rsbuild configuration docs](https://rsbuild.rs/config/) for more information.
|
|
1305
|
+
Please note that not all Rsbuild options are supported in Nuxt.
|
|
1306
|
+
|
|
1307
|
+
Sass, Less, Stylus and Pug are compiled by their Rsbuild plugins (`@rsbuild/plugin-sass`, `@rsbuild/plugin-less`, `@rsbuild/plugin-stylus` and `@rsbuild/plugin-pug`), which Nuxt registers when they are installed in your project. When a file needs one that is not installed, Nuxt offers to install it.
|
|
1308
|
+
|
|
1309
|
+
### `vue`
|
|
1310
|
+
|
|
1311
|
+
Options passed to [`@rsbuild/plugin-vue`](https://rsbuild.rs/plugins/list/plugin-vue). By default, `vueLoaderOptions` uses the `vue.compilerOptions`, `vue.transformAssetUrls` and `vue.propsDestructure` options.
|
|
1312
|
+
|
|
1313
|
+
- **Type**: `object`
|
|
1314
|
+
|
|
1273
1315
|
## runtimeConfig
|
|
1274
1316
|
|
|
1275
1317
|
Runtime config allows passing dynamic config and environment variables to the Nuxt app context.
|
|
@@ -11,7 +11,8 @@ Once you've read the [general contribution guide](/docs/community/contribution),
|
|
|
11
11
|
- `packages/kit`: Toolkit for authoring Nuxt modules, published as [`@nuxt/kit`](https://www.npmjs.com/package/@nuxt/kit).
|
|
12
12
|
- `packages/nuxt`: The core of Nuxt, published as [`nuxt`](https://www.npmjs.com/package/nuxt).
|
|
13
13
|
- `packages/schema`: Cross-version Nuxt typedefs and defaults, published as [`@nuxt/schema`](https://www.npmjs.com/package/@nuxt/schema).
|
|
14
|
-
- `packages/
|
|
14
|
+
- `packages/rsbuild`: The [Rsbuild](https://rsbuild.rs) bundler for Nuxt, published as [`@nuxt/rsbuild-builder`](https://www.npmjs.com/package/@nuxt/rsbuild-builder).
|
|
15
|
+
- `packages/rspack`: The deprecated [Rspack](https://rspack.rs) bundler for Nuxt (superseded by `@nuxt/rsbuild-builder`), published as [`@nuxt/rspack-builder`](https://www.npmjs.com/package/@nuxt/rspack-builder).
|
|
15
16
|
- `packages/vite`: The [Vite](https://vite.dev) bundler for Nuxt, published as [`@nuxt/vite-builder`](https://www.npmjs.com/package/@nuxt/vite-builder).
|
|
16
17
|
- `packages/webpack`: The [webpack](https://webpack.js.org) bundler for Nuxt, published as [`@nuxt/webpack-builder`](https://www.npmjs.com/package/@nuxt/webpack-builder).
|
|
17
18
|
|