# 插件配置

> Source: https://strapi.nodejs.cn/cms/configurations/plugins

🌐 Plugins configuration

`/config/plugins` 启用或禁用插件并覆盖其设置，并提供用于本地插件开发的示例。

插件配置存储在 `/config/plugins.js|ts` 中（参见 [项目结构](/cms/project-structure)）。每个插件可以使用以下可用参数进行配置：

🌐 Plugin configurations are stored in `/config/plugins.js|ts` (see [project structure](/cms/project-structure)). Each plugin can be configured with the following available parameters:

| 参数 | 描述 | 类型 |
| --- | --- | --- |
| `enabled` | 启用 (`true`) 或禁用 (`false`) 已安装的插件 | 布尔值 |
| `config`<br/><br/>_可选_ | 用于覆盖默认插件配置（[在 strapi-server.js 中定义](/cms/plugins-development/server-configuration)） | 对象 |
| `resolve`<br/> _可选，仅本地插件需要_ | 插件文件夹的路径 | 字符串 |

:::note Configurations for core features and providers

* Strapi 的一些核心功能历来是作为核心插件实现的。这就解释了为什么它们的配置仍然在 `/config/plugins` 文件中定义，尽管从技术上讲它们在 Strapi 5 中不再是插件。这包括：
  - 为支持媒体库的包的[上传配置](/cms/features/media-library#available-options)，
  - 以及[用户与权限配置](/cms/features/users-permissions#code-based-configuration)。

  详细的 [GraphQL 插件配置](/cms/plugins/graphql#code-based-configuration) 也记录在其专用插件页面中。

* 此外，媒体库和电子邮件功能的提供者配置也在 `/config/plugins` 中定义。它们的配置详见 [上传提供者配置](/cms/features/media-library#code-based-configuration) 和 [电子邮件提供者配置](/cms/features/email#providers)。

:::

**插件的基础自定义配置示例：**

```js title="./config/plugins.js"

module.exports = ({ env }) => ({
  // enable a plugin that doesn't require any configuration
  i18n: true,

  // enable a custom plugin
  myplugin: {
    // my-plugin is going to be the internal name used for this plugin
    enabled: true,
    resolve: './src/plugins/my-local-plugin',
    config: {
      // user plugin config goes here
    },
  },

  // disable a plugin
  'my-other-plugin': {
    enabled: false, // plugin installed but disabled
  },
});
```

```ts title="./config/plugins.ts"

  // enable a plugin that doesn't require any configuration
  i18n: true,

  // enable a custom plugin
  myplugin: {
    // my-plugin is going to be the internal name used for this plugin
    enabled: true,
    resolve: './src/plugins/my-local-plugin',
    config: {
      // user plugin config goes here
    },
  },

  // disable a plugin
  'my-other-plugin': {
    enabled: false, // plugin installed but disabled
  },
});
```

:::tip

如果不需要特定配置，插件也可以使用简写语法 `'plugin-name': true` 来声明。

🌐 If no specific configuration is required, a plugin can also be declared with the shorthand syntax `'plugin-name': true`.

:::
