监视管理员模式默认是开启的
🌐 The watch-admin mode is enabled by default
Page summary:在 Strapi 5 中,
strapi develop默认以 watch-admin 模式启动,所以管理面板会自动热重载,无需额外的标志。使用--no-watch-admin可以禁用它。🌐 In Strapi 5,
strapi developstarts in watch-admin mode by default, so the admin panel hot reloads without any additional flag. Use--no-watch-adminto disable it.
Watch-admin 模式会在你编辑管理面板的源文件时自动重新加载。在 Strapi v4 中,你需要明确要求这种行为,而在 Strapi 5 中默认就会这样,你可以选择关闭。
🌐 Watch-admin mode reloads the admin panel automatically while you edit its source files. In Strapi v4 you had to ask for this behavior explicitly, while in Strapi 5 you get it by default and opt out instead.
此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。
🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.
重大变更描述
🌐 Breaking change description
在 Strapi v4 中
观看管理员模式默认是关闭的。你可以用 --watch-admin 标志来开启它:
🌐 Watch-admin mode is disabled by default. You start it with the --watch-admin flag:
strapi develop --watch-admin
也有一个单独的 strapi watch-admin 命令可用。
🌐 A separate strapi watch-admin command is also available.
在 Strapi 5 中
Watch-admin 模式默认开启,所以只用 strapi develop 就可以热重载管理面板。--no-watch-admin 标志可以禁用它:
🌐 Watch-admin mode is enabled by default, so strapi develop alone hot reloads the admin panel. The --no-watch-admin flag disables it:
strapi develop --no-watch-admin
独立的 strapi watch-admin 命令已被移除。
🌐 The standalone strapi watch-admin command is removed.
迁移
🌐 Migration
本节重新组合了有关引入的重大更改的有用说明和程序。
🌐 This section regroups useful notes and procedures about the introduced breaking change.
注意
🌐 Notes
在 Strapi 5 中传入 --watch-admin 并不是错误,因为这个标志仍然存在并且已经默认是 true。使用它的脚本仍然可以正常工作,但这个标志已经没有必要了。
🌐 Passing --watch-admin in Strapi 5 is not an error, since the flag still exists and already defaults to true. Scripts that use it keep working, but the flag is redundant.
如果禁用了 watch-admin 模式,你也可以使用 --no-build-admin 来阻止管理面板的构建。
🌐 If watch-admin mode is disabled, you can also use --no-build-admin to prevent the admin panel from being built.
手动迁移
🌐 Manual migration
要迁移到 Strapi 5:
🌐 To migrate to Strapi 5:
- 在你的
package.json脚本、Dockerfiles 和 CI 配置文件中搜索--watch-admin和strapi watch-admin。 - 将任何
strapi watch-admin命令替换为strapi develop。 - 现在可以移除多余的
--watch-admin标志,当然如果你喜欢明确 一点,也可以保留它们。 - 将
--no-watch-admin添加到那些不能热重载管理面板的命令中,比如之前依赖于默认关闭 watch-admin 模式的脚本。
查看 CLI 参考 了解 strapi develop 命令支持的所有选项。
🌐 See the CLI reference for the full list of options accepted by the strapi develop command.