---
title: "配置"
description: "了解如何根据自己的需求配置 Nuxt Bridge。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/bridge/configuration"
---
# 配置

> 了解如何根据自己的需求配置 Nuxt Bridge。

## 功能开关

你可以选择性地禁用 Bridge 的某些功能或选择不太稳定的功能。在正常情况下，最好保持默认设置！

你可以查看 [bridge/src/module.ts](https://github.com/nuxt/bridge/blob/main/packages/bridge/src/module.ts) 以获取最新默认值。

```ts [nuxt.config.ts]
import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  bridge: {

    // -- 可选功能 --

    // 使用 Vite 作为打包器而不是 webpack 4
    // vite: true,

    // 启用与 Nuxt 3 兼容的 useHead
    // meta: true,

    // 启用 definePageMeta 宏
    // macros: {
    //   pageMeta: true
    // },

    // 启用使用 esbuild 转译 TypeScript
    // typescript: {
    //   esbuild: true
    // },

    // -- 默认功能 --

    // 使用旧版服务器而不是 Nitro
    // nitro: false,

    // 禁用与 Nuxt 3 兼容的 `nuxtApp` 接口
    // app: false,

    // 禁用 Composition API 支持
    // capi: false,

    // ... 或者只禁用旧版 Composition API 支持
    // capi: {
    //   legacy: false,
    // },

    // 不转译模块
    // transpile: false,

    // 禁用 <script setup> 支持
    // scriptSetup: false,

    // 禁用 composables 自动导入
    // imports: false,

    // 不要警告模块不兼容
    // constraints: false
  },

  vite: {
    // Vite 的配置
  },
})
```

## 每个选项的迁移

### router.base

```diff
export default defineNuxtConfig({
- router: {
-   base: '/my-app/'
- }
+ app: {
+   baseURL: '/my-app/'
+ }
})
```

### build.publicPath

```diff
export default defineNuxtConfig({
- build: {
-   publicPath: 'https://my-cdn.net'
- }
+ app: {
+   cdnURL: 'https://my-cdn.net'
+ }
})
```


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
