gulp-uglify引起构造函数。名称不当行为

发布于 2025-02-07 09:58:12 字数 669 浏览 0 评论 0原文

在我的gulpfile.js中,如果我评论这一行

.pipe(uglify({ preserveComments: 'some'}))

,那么我的代码看起来并不丑陋,并且为了遵循代码行,一切正常。

if(Mystudy.constructor.name != "MyStudyView")

但是,如果我使用Gulp-uglify对我的代码进行了统计(不在最上面评论该uglify代码) 然后上面的行看起来像这样

if ("MyStudyView" != e.constructor.name)

,e.constructor.name的价值也变得像“ E”一样丑陋,而不是“ MystudyView”。

我想以与不uglify的工作相同的方式运行代码,并且我也不想在uglify上妥协,我有什么办法可以实现自己想要的东西吗?

额外信息: 该“如果”条件代码写在mystudy.js的文件名中,以及函数collectit下方。

In my gulpfile.js if I comment this line

.pipe(uglify({ preserveComments: 'some'}))

then my code is not looking ugly and for following line of code everything is working fine.

if(Mystudy.constructor.name != "MyStudyView")

but if I uglify my code using gulp-uglify(without commenting that uglify code on top)
then the above line looks something like this

if ("MyStudyView" != e.constructor.name)

and value of e.constructor.name is also getting ugly like "e" instead of the "MyStudyView".

I want to run my code the same way as it was working without uglifying and I don't want to compromise on the uglify as well, is there any way that I can achieve what I want?

Extra information:
That "if" condition code is written in the filename of mystudy.js and under the function closeIt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2025-02-14 09:58:12

而不是

if(Mystudy.constructor.name != "MyStudyView")

写写

if(Mystudy.constructor.name != MyStudyView.name)

Instead of writing

if(Mystudy.constructor.name != "MyStudyView")

write

if(Mystudy.constructor.name != MyStudyView.name)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文