You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在esbuild构建输出中禁用源文件路径注释?

解决esbuild输出文件开头包含源文件路径注释的问题

在使用esbuild.build()构建时,输出文件开头的源文件路径注释是esbuild默认开启的行为,只需在构建选项中添加sourceComment: false即可禁用该注释。

示例代码:

const esbuild = require('esbuild');

esbuild.build({
  entryPoints: ['your-entry-file.js'],
  outfile: 'dist/output.js',
  // 禁用源文件路径注释
  sourceComment: false,
  // 其他构建选项...
}).catch(err => {
  console.error(err);
  process.exit(1);
});

设置后,输出文件就不会再包含开头的源文件路径注释了。

内容的提问来源于stack exchange,提问作者Raghavan Vidhyasagar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 17:21:14