'linked' | 'inline' | 'none'
'linked'
配置 legal comments 的处理方式。
Legal comments 是 JS 或 CSS 文件中的一些特殊注释,这些注释包含 @license
或 @preserve
,或是以 //!
开头。默认情况下,这些注释保留在输出文件中,因为这遵循了代码原作者的意图。
例如 React 的 LICENSE
注释:
/**
* @license React
* react.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
你可以通过 legalComments
来配置如何处理 legal comments:
linked
将所有 legal comments 移至 *.LICENSE.txt
文件,并通过注释链接到它们。
export default {
output: {
legalComments: 'linked',
},
};
.LICENSE.txt
文件不会被页面加载,因此它们不会影响页面的性能。
inline
保留所有 legal comments 在代码的原始位置。这可能会导致输出文件的体积变大。
export default {
output: {
legalComments: 'inline',
},
};
none
移除所有 legal comments。
export default {
output: {
legalComments: 'none',
},
};
移除 license 注释可能会违反部分开源软件的许可协议要求。在使用此选项前,请确认你具有移除这些注释的权利。