首页 > 解决方案 > 在 create-react-app (react-scripts v4) 中保留注释

问题描述

有什么方法可以在 create-react-app 的源代码中保留一些注释(在撰写本文时,react-scripts v4.0.3)?我正在尝试将这样的评论保留在生产版本中:

/**
 * @license Copyright (c) blah blah blah
 * Written by Blah blah
 */

我看到这个关于这个问题的 GitHub 问题:https ://github.com/facebook/create-react-app/issues/4596

据说它是由这个 PR 修复的:https ://github.com/facebook/create-react-app/pull/4601#issuecomment-424589230

但根据此评论,使用 Terser 而不是 Uglify https://github.com/facebook/create-react-app/pull/4601#issuecomment-424589230

我看到在生产版本中保留了几个许可证注释node_modules,我想我可以有一个模块只是为了包含许可证信息,但如果可能的话,我真的很想在源代码中保留注释。

标签: reactjscreate-react-appreact-scripts

解决方案


推荐阅读