只有在MVC4 BundleConfig缩小的脚本 [英] Minified script only in MVC4 BundleConfig

查看:121
本文介绍了只有在MVC4 BundleConfig缩小的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加在BundleConfig以下ScriptBundle:

I am adding the following ScriptBundle in BundleConfig:

    bundles.Add(new ScriptBundle("~/bundles/javascript").Include(
        "~/Scripts/jquery-1.*",
        "~/Scripts/load-image.min.js",
        "~/Scripts/bootstrap.*",
        "~/Scripts/bootstrap-image-gallery.*",
        "~/Scripts/my.global.js"));

这是我的_Layout.cshtml年底为引用:

This is referenced at the end of my _Layout.cshtml as:

@Scripts.Render("~/bundles/javascript")

在调试我注意到,这个脚本渲染的输出是:

When debugging I notice that the output of this script rendering is:

<script src="/Scripts/jquery-1.8.2.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/bootstrap-image-gallery.js"></script>
<script src="/Scripts/my.global.js"></script>

的通知负载image.min.js脚本不见了?我想是使用相同的脚本缩小的是否我调试与否。下释放条件的脚本包含在捆绑JS文件。

Notice the load-image.min.js script is missing? What I want is to use that same minified script whether I'm debugging or not. Under release conditions the script is included in the bundled JS file.

我以为它看到'分',寻找一个未精缩版,没有找到一个,然后决定什么是最好就是完全忽略它。辉煌。如果我做负载image.min.js的副本,称之为负载image.js然后引用它BundleConfig为加载图像。*我觉得它是包含在这两个配置,但什么是必须的点去做?

I assume it's seeing the 'min', looking for an un-minified version, not finding one, then deciding what's best is to ignore it entirely. Brilliant. If I make a copy of load-image.min.js, call it load-image.js and then reference it in BundleConfig as "load-image.*" I find it is included in both configurations but what's the point of having to do that?

我想我在这里失去了一些东西。我没有未缩小的版本,我坦率地不关心它。它使用我的引导图片库的插件而已。任何想法了吗?

I assume I'm missing something here. I don't have the un-minified version and I frankly don't care about it. It's used by my Bootstrap image gallery plugin and nothing else. Any ideas out there?

推荐答案

此行​​为已改善(固定)的0.9.6版本。我们将所有的旧的默认的忽略列表中的条目到一个新的DirectoryFilter忽略,包括像* .js文件这是此功能的原始意图的搜索模式时仅用于名单。因此这应该不再是一个问题,当你明确包括个人文件。

This behavior has been improved (fixed) in the 1.1.0-alpha1 release. We moved all of the old default ignore list entries into a new DirectoryFilter ignore list that are only used when including search patterns like *.js which was the origional intent for this functionality. As a result this should no longer be an issue when you are including individual files explicitly.

请注意:一个地方,这可能仍然是一个问题是,如果你尝试包括像jquery- {}版本.min.js。

Note: the one place this might still be an issue is if you try to include something like jquery-{version}.min.js.

这篇关于只有在MVC4 BundleConfig缩小的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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