如何删除与BundleTransformer YuiJsMinifier评论 [英] How to remove comments with BundleTransformer YuiJsMinifier

查看:294
本文介绍了如何删除与BundleTransformer YuiJsMinifier评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 BundleTransformer 来缩小 CSS JS 资源

        <yui>
            <css compressionType="Standard" removeComments="true" lineBreakPosition="-1" />
            <js compressionType="Standard" obfuscateJavascript="true" preserveAllSemicolons="false" disableOptimizations="false" ignoreEval="false" severity="0" lineBreakPosition="-1" encoding="UTF8" threadCulture="en-us" />
        </yui>

正如你可以看到 CSS 可以指定 removeComments =真正的
但在 JS 有没有这样的选择。

As you can see for css it is possible to specify removeComments="true" But in js there is no such option.

我红认为,YUI的js COM pressor ​​删除默认意见。是的,它是一种消除了,但它仍然留下这样的评论:

I red that YUI js compressor removes comments by default. Yes it is kind of removes, but it is still leave comments like that:

/* NUGET: BEGIN LICENSE TEXT
 *
 *Bla bla bla
 *
 * NUGET: END LICENSE TEXT */

/*!
 * Bla
 * Licensed under http://www.apache.org/licenses/LICENSE-2.0
 */

看起来是没有办法强迫耀JS minifier删除评论。

Looks like there is no way to force YIU js minifier to remove comments.

https://github.com/yui/yuicom$p$pssor ​​

C风格的注释以/ *!是preserved。这是与有用
  包含版权/许可证信息注释

C-style comments starting with /*! are preserved. This is useful with comments containing copyright/license information

有什么我可以使用 BundleTransformer 完全删除所有种类的捆绑缩小的意见办输出文件? 谷歌网页速度强烈建议我这样做。

Is there anything I can do by using BundleTransformer to completely remove all kind of comments in bundled minified output files? Google page speed strongly recommended me to do that.

推荐答案

YUI COM pressor不支持删除的重要意见。

YUI compressor does not support removing of important comments.

我建议你安装 BundleTransformer.MicrosoftAjax 包。此后注册 MicrosoftAjaxCssMinifier MicrosoftAjaxJsMinifier 默认minifiers,并添加到Web.config文件中的以下配置设置:

I recommend you to install BundleTransformer.MicrosoftAjax package. Thereafter register MicrosoftAjaxCssMinifier and MicrosoftAjaxJsMinifier as default minifiers, and add to the Web.config file the following configuration settings:

<configuration>
    …
    <bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
        …
        <microsoftAjax>
            <css commentMode="None" />
            <js preserveImportantComments="false" />
        </microsoftAjax>
        …
    </bundleTransformer>
    …
</configuration>

这篇关于如何删除与BundleTransformer YuiJsMinifier评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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