在 webpack 文件顶部包含注释 [英] Include comment at top of webpack file

查看:34
本文介绍了在 webpack 文件顶部包含注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 webpack 将一堆 javascript 文件捆绑在一起,我需要在文件顶部包含版权声明.我似乎无法弄清楚如何做到这一点,或者是否可能.

I'm using webpack to bundle a bunch of javascript files together, and I need to include a copyright notice at the top of the file. I can't seem to figure out how to do that, or if it is possible.

我最接近的是使用原始加载程序,但这隐藏了导出函数中的版权.任何的想法.

The closest I've come is to use the raw loader, but that hides the copyright in an exported function. Any idea.

最好是跨平台的.

推荐答案

你可以使用 webpack 横幅插件.使用此插件,您可以在捆绑文件的顶部添加您想要的任何字符串.

You can use the webpack BannerPlugin. With this plugin you can add any string you want at the top of your bundled file.

我用它在 我自己的库.

module.exports = {
  // Other stuff
  plugins: [
    new webpack.BannerPlugin('Your copyright notice')
  ]
};

这篇关于在 webpack 文件顶部包含注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆