Skip to main content

插件 SDK 参考

¥Plugin SDK reference

插件 SDK 是 @strapi/sdk-plugin 包提供的一组命令,用于开发插件以将其用作本地插件或将它们发布在 NPM 上和/或将它们提交到 Marketplace。

¥The Plugin SDK is set of commands provided by the package @strapi/sdk-plugin orientated around developing plugins to use them as local plugins or to publish them on NPM and/or submit them to the Marketplace.

本文档列出了可用的插件 SDK 命令。相关指南 说明了如何使用这些命令从头开始创建插件、将其链接到现有项目并发布它。

¥The present documentation lists the available Plugin SDK commands. The associated guide illustrates how to use these commands to create a plugin from scratch, link it to an existing project, and publish it.

npx @strapi/sdk-plugin init

在给定路径创建一个新插件。

¥Create a new plugin at a given path.

npx @strapi/sdk-plugin init
参数类型描述默认
pathstring插件路径./src/plugins/my-plugin
选项类型描述默认
-d, --debug*启用带有详细日志的调试模式false
--silent*不记录任何内容false

strapi-plugin build

打包 Strapi 插件以进行发布。

¥Bundle the Strapi plugin for publishing.

strapi-plugin build
选项类型描述默认
--forcestring自动回答 "yes" 所有提示,包括潜在的破坏性请求,并以非交互方式运行。*
-d, --debug*启用带有详细日志的调试模式false
--silent*不记录任何内容false
--minify*缩小输出true
--sourcemaps*生成源映射false

在更改时自动重新编译插件并运行 yalc push --publish

¥Recompiles the plugin automatically on changes and runs yalc push --publish.

出于测试目的,将你的插件链接到现有应用以在真实条件下进行试验非常方便。此命令旨在帮助你简化此过程。

¥For testing purposes, it is very convenient to link your plugin to an existing application to experiment with it in real condition. This command is made to help you streamline this process.

strapi-plugin watch:link
选项类型描述默认
-d, --debug*启用带有详细日志的调试模式false
--silent*不记录任何内容false

strapi-plugin watch

观察插件源代码是否有任何更改,并每次都重建它。在实现插件并在应用中测试它时很有用。

¥Watch the plugin source code for any change and rebuild it everytime. Useful when implementing your plugin and testing it in an application.

strapi-plugin watch
选项类型描述默认
-d, --debug*启用带有详细日志的调试模式false
--silent*不记录任何内容false

strapi-plugin verify

在发布插件之前验证插件的输出。

¥Verify the output of the plugin before publishing it.

strapi-plugin verify
选项类型描述默认
-d, --debug*启用带有详细日志的调试模式false
--silent*不记录任何内容false