javascript缩小删除许可证? [英] javascript minification that removes licenses?

查看:64
本文介绍了javascript缩小删除许可证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Javascript缩小通常会从源中删除所有注释。这意味着还会删除许可证信息。

Javascript minification will generally remove all comments from source. This means that license information is also removed.

如果我经营一个大型网站,并且我想遵守许可证,这是否意味着我不能使用自动缩小功能?没有选项可以保留第一条评论,但不保留其他条款
对吗?

If I run a big site, and I want to abide by licenses, does that mean that I cannot use automatic minification? There is no option to "preserve the first comment, but not the others " right?

我问,因为一家相当大的公司使用了我写的一些代码而且不包括我的(麻省理工学院)执照,但在我感到很恼火之前,我想把自己放在自己的位置。

I ask because a rather big company has used some code I wrote and not included my (MIT) license, but before I get all peeved, I want to put myself in their shoes.

编辑

似乎作为作者,我有责任以这种方式评论许可证(见答案)它在缩小过程中不会被删除。我可以先做这件事,然后如果我的许可仍然被删除则引发恶臭

推荐答案

这是依赖的经典案例。

这取决于缩小器。例如,UglifyJS将留在初始注释块中在文件中,除非您明确告诉它不要使用 -nc 标志。其他人(如Google的Closure Compiler)寻找特殊注释(例如, @license @preserve )。有些人尊重大声的评论(例如, / *!... * / ),而其他人则没有。

It depends on the minifier. For example UglifyJS will leave in the initial comment block in a file unless you specifically tell it not to with the -nc flag. Others (like Google's Closure Compiler) look for a special annotation (e.g., @license or @preserve). Some respect "loud" comments (e.g., /*! ... */) while others don't.

这取决于你如何缩小。一些组织正在积极地缩小和连接所有内容以挤出每个字节。其他人则在源控制中添加许可证,并在缩小期间将其留在中。其他人在将所有内容连接在一起后应用许可文件

It depends how you minify. Some organization are aggressively minifying and concatenating everything to squeeze out every byte. Others are adding the licenses in source control and "leaving them in" during minifying. Others are applying license files after everything has been concatenated together.

某些地方可以很容易地将许可证放入其生产版本中,特别是如果他们积极地将他们使用的每个库连接成一个JS文件。他们甚至可能都不知道他们正在这样做。这里你最好的选择可能只是伸出援手,要求他们确保他们尊重许可条款并将许可文本留在那里 - 他们甚至可能没有意识到他们正在这样做。

It can be easy for some place to drop a license in their production builds, especially if they're aggressively concatenating every library they use into a single JS file. They may not even know that they're doing it. Your best bet here is probably just to reach out and ask them to make sure that they're respecting the terms of the license and leave the license text on there -- they may not even realize that they're doing it.

这篇关于javascript缩小删除许可证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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