为什么uglify-js报告“警告:输出超过32000个字符”? [英] Why does uglify-js report 'WARN: Output exceeds 32000 characters'?

查看:162
本文介绍了为什么uglify-js报告“警告:输出超过32000个字符”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 构建管道为:Typescript,browserify,browserify-css,uglify。

  • 运行时库:react,bootstrap。

到目前为止,我的应用程序功能很少(这就是为什么我问这是否会在以后给我带来麻烦,即使它似乎现在可以正常工作)。稍后它将变得更大(反应路由器,redux,其他js库(如Auth0,甚至可能还有一些实际功能)。)

My application so far has very little functionality (that's why I'm asking if this is going to bite me later, even though it appears to work for now). Later on it will get bigger (react-router, redux, other js libraries like Auth0, maybe even some actual functionality.)

我有一个 app.css 包含:

@import url("node_modules/bootstrap/dist/css/bootstrap.css");

然后我将其导入到我的 index.tsx 与:

I then import that into my index.tsx with:

import './app.css';

这一切似乎都起作用,因为我的helloworld react组件显示 hello world。

This all appears to work in that my helloworld react component displays "hello world".

但是,在生成过程中,会丑化报告:

But, during the build, uglify reports:

WARN: Output exceeds 32000 characters

我应该忽略它吗?

查看uglify生成的文件表明,它似乎可以确保没有行超过32000个字符-大多数行在短于32000时截断(在31999时截断)。

Looking at the file produced by uglify shows that it seems to make sure no lines are > 32000 characters - most lines truncate at just short of 32000 (one at 31999).

但是只有一行 var css ='/ *!\n * Bootstrap v3 .3.7 ...',长度为12万个字符。我认为这是Uglify试图告诉我的,但是有什么大不了的呢?

But there's one line var css='/*!\n * Bootstrap v3.3.7 ...' that is 120K characters long. I assume this is what Uglify is trying to tell me, but what's the big deal?

推荐答案

根据DavidG的评论,您可以使用 max-line-len 选项告诉Uglify不要抱怨。

As per DavidG's comment, you can tell Uglify not to complain about this with the max-line-len option.

但是,您不能只需添加该选项,因为它仅在美化代码时才有效。

But, you can't just add that option, because it only works if you're "beautifying" the code. Which then does other stuff that you may not want to do.

解决方案是使用 -b 选项以启用美化功能,但随后告诉Uglify不要实际美化。 o_O

The solution to that is to use the -b option to enable beautification, but then tell Uglify not to actually beautify. o_O

"scripts": {
  "uglifyjs":"uglifyjs -b beautify=false,max-line-len=120000"
}

上面的代码将行长设置为120K-警告会消失。

The above will set the line length to 120K - which made the warning go away.

尽管这是解决方法,而不是答案-它回答了我的问题的如何抑制它部分。我仍然不知道为什么为什么向我发出警告-较旧的浏览器或任何我不知道的问题。

This is more of a workaround than an answer though - it answers the "how do I suppress it" part of my question. I still don't know why it's warning me about that - problems with older browsers or whatever, I don't know.

这篇关于为什么uglify-js报告“警告:输出超过32000个字符”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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