插件配置
¥Plugins configuration
插件配置存储在 /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 可选,仅本地插件需要 | 插件文件夹的路径 | 字符串 |
注意
Strapi 的一些功能由插件提 供,以下插件也可以具有特定的配置选项:为媒体库提供支持的 GraphQL 插件和 上传 包。
¥Some features of Strapi are provided by plugins and the following plugins can also have specific configuration options: the GraphQL plugin and the Upload package which powers the Media Library.
插件的基本示例自定义配置:
¥Basic example custom configuration for plugins:
- JavaScript
- TypeScript
./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
},
});
./config/plugins.ts
export default ({ 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
},
});
提示
如果不需要具体配置,也可以使用简写语法 'plugin-name': true
来声明插件。
¥If no specific configuration is required, a plugin can also be declared with the shorthand syntax 'plugin-name': true
.