Skip to main content

插件配置

🌐 Plugins configuration

Page summary:

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

插件配置存储在 /config/plugins.js|ts 中(参见 项目结构)。每个插件可以使用以下可用参数进行配置:

🌐 Plugin configurations are stored in /config/plugins.js|ts (see project structure). Each plugin can be configured with the following available parameters: | 参数 | 描述 | 类型 || --- | --- | --- || enabled | 启用 (true) 或禁用 (false) 已安装的插件 | 布尔值 || config

可选 | 用于覆盖默认插件配置(在 strapi-server.js 中定义) | 对象 || resolve
可选,仅本地插件需要 | 插件文件夹的路径 | 字符串 |

Configurations for core features and providers
  • Strapi 的一些核心功能历来是作为核心插件实现的。这就解释了为什么它们的配置仍然在 /config/plugins 文件中定义,尽管从技术上讲它们在 Strapi 5 中不再是插件。这包括:

    详细的 GraphQL 插件配置 也记录在其专用插件页面中。

  • 此外,媒体库和电子邮件功能的提供者配置也在 /config/plugins 中定义。它们的配置详见 上传提供者配置电子邮件提供者配置

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

./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
},
});
Tip

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

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