简体   繁体   English

汇总:如何在文件开头添加一行?

[英]rollup: How do I prepend a line to the beginning of my file?

I am using rollup to generate a single JavaScript file.我正在使用汇总生成单个 JavaScript 文件。 I want to put a line at the beginning of this JavaScript file that looks like this:我想在这个 JavaScript 文件的开头添加一行,如下所示:

This is a line of my choosing

I'd been googling for a while and can't figure out how to do this.我已经在谷歌上搜索了一段时间,无法弄清楚如何做到这一点。 I found a banner plug-in, but the problem is it puts a comment at the beginning of the line you prepend, and I don't want that.我找到了一个横幅插件,但问题是它在您添加的行的开头添加了注释,而我不希望这样。 I found and insert plug-in, but that inserted the line on every file, and it did it inside the iife.我找到并插入插件,但是在每个文件上都插入了该行,并且它在 iife. I want this line only once at the beginning of the file and outside the IIFE.我只希望这一行在文件开头和 IIFE 之外出现一次。

How do you prepend a line to the beginning of your rollup output file?如何在汇总 output 文件的开头添加一行?

desen't the 'output.banner' option itself work? desen 'output.banner' 选项本身不起作用吗?

// rollup.config.js
export default {
  ...,
  output: {
    ...,
    banner: 'This is a line of my choosing',
  }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM