如何美元BundleTransformer * .min.js的对$ pvent使用情况如何? [英] How to prevent usage of *.min.js in BundleTransformer?

查看:265
本文介绍了如何美元BundleTransformer * .min.js的对$ pvent使用情况如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 BundleTransformer.Core 25年9月1日。我在包包含的角animate.js 的。但是,在生成的包文件我看到的错误:

I use BundleTransformer.Core 1.9.25. I have included angular-animate.js in bundle. But in generated bundle file I saw the error:

/* Minification failed. Returning unminified contents.
(402,118-125): run-time error JS1019: Can't have 'break' outside of loop: break a

究其原因是,该包使用的角animate.min.js 的而不是角animate.js 的的。当我删除的角animate.min.js 的文件,它使用的角animate.js 的并没有错误。

The reason is that the bundle uses angular-animate.min.js instead of angular-animate.js. When I delete angular-animate.min.js file, it uses angular-animate.js and there is not errors.

的Web.config 的包括:

<bundleTransformer xmlns="http://tempuri.org/BundleTransformer.Configuration.xsd">
  <core>
    <js usePreMinifiedFiles="false">
      <translators>
        <add name="NullTranslator" type="BundleTransformer.Core.Translators.NullTranslator, BundleTransformer.Core" enabled="false" />
      </translators>
      <minifiers>
        <add name="NullMinifier" type="BundleTransformer.Core.Minifiers.NullMinifier, BundleTransformer.Core" />
      </minifiers>
      <fileExtensions>
        <add fileExtension=".js" assetTypeCode="JavaScript" />
      </fileExtensions>
    </js>
  </core>
</bundleTransformer>

正如你所看到使用preMinifiedFiles = FALSE 属性不存在的prevent使用的 *。min.js 的文件

As you see usePreMinifiedFiles=false attribute doesn't prevent usage of existing *.min.js files.

推荐答案

我只是忘了添加 ScriptTransformer 中的 App_Start / BundleConfig.cs 的:

I just forgot to add ScriptTransformer in App_Start/BundleConfig.cs:

var scriptTransformer = new ScriptTransformer();
bundle.Transforms.Add(scriptTransformer);

这解决了这一问题。

It fixed the problem.

不过,我选择的是解决方案,而无需使用 ScriptTransformer (BundleTransformer.Core)。它是清洁 FileExtensionReplacementList 清单:

But I chose the solution without using ScriptTransformer (BundleTransformer.Core). It is cleaning of FileExtensionReplacementList list:

bundles.FileExtensionReplacementList.Clear();

在默认情况下 FileExtensionReplacementList 有两个值:

.Add("min", OptimizationMode.WhenEnabled);
.Add("debug", OptimizationMode.WhenDisabled);

和这是我的问题的原因。

And it was a cause of my problem.

这篇关于如何美元BundleTransformer * .min.js的对$ pvent使用情况如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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