Skip to main content
Version: 3.5.1

📦 plugin-debug

调试插件将在 http://localhost:3000/__docusaurus/debug 显示有用的调试信息。

¥The debug plugin will display useful debug information at http://localhost:3000/__docusaurus/debug.

它对于插件作者来说非常有用,他们将能够更轻松地检查 .docusaurus 文件夹的内容(例如创建路由),而且还能够检查从未写入磁盘的数据结构,例如通过 加载的插件数据 contentLoaded 生命周期。

¥It is mostly useful for plugin authors, that will be able to inspect more easily the content of the .docusaurus folder (like the creates routes), but also be able to inspect data structures that are never written to disk, like the plugin data loaded through the contentLoaded lifecycle.

信息

如果你通过经典预设使用该插件,预设将在开发中启用该插件,并在生产中默认禁用它(debug: undefined),以避免暴露潜在的敏感信息。你可以使用 debug: true 始终启用它或使用 debug: false 始终禁用它。

¥If you use the plugin via the classic preset, the preset will enable the plugin in development and disable it in production by default (debug: undefined) to avoid exposing potentially sensitive information. You can use debug: true to always enable it or debug: false to always disable it.

如果使用独立插件,可能需要通过检查环境来达到相同的效果:

¥If you use a standalone plugin, you may need to achieve the same effect by checking the environment:

docusaurus.config.js
export default {
plugins: [
process.env.NODE_ENV === 'production' && '@docusaurus/plugin-debug',
].filter(Boolean),
};
注意

如果你报告错误,我们可能会要求你在生产中打开此插件,以便我们可以更轻松地检查你的部署配置。

¥If you report a bug, we will probably ask you to have this plugin turned on in the production, so that we can inspect your deployment config more easily.

如果你没有任何敏感信息,则可以将其保留在生产 就像我们一样 中。

¥If you don't have any sensitive information, you can keep it on in production like we do.

安装

¥Installation

npm install --save @docusaurus/plugin-debug
提示

如果你使用预设 @docusaurus/preset-classic,则无需安装此插件作为依赖。

¥If you use the preset @docusaurus/preset-classic, you don't need to install this plugin as a dependency.

你可以通过 预设选项.conf 配置该插件。

¥You can configure this plugin through the preset options.

配置

¥Configuration

该插件目前没有选项。

¥This plugin currently has no options.

配置示例

¥Example configuration

你可以通过预设选项或插件选项配置此插件。

¥You can configure this plugin through preset options or plugin options.

提示

大多数 Docusaurus 用户通过预设选项配置此插件。

¥Most Docusaurus users configure this plugin through the preset options.

如果你使用预设,请通过 预设选项 配置此插件:

¥If you use a preset, configure this plugin through the preset options:

docusaurus.config.js
export default {
presets: [
[
'@docusaurus/preset-classic',
{
debug: true, // This will enable the plugin in production
},
],
],
};