ASP.Net MVC包和缩小 [英] ASP.Net MVC Bundles and Minification
问题描述
在从开发迁移到生产环境中我遇到了一些问题,在我的JavaScript文件被缩小的方式。这似乎有些不正常运行如下,所以我一直在寻找周围找到一种方法,不运行如下特定的捆绑。
When moving from development to a production environment I have run into some problems with the way in which my javascript files are being minified. It seems that some do not minify properly, and so I have been looking around to find a way to not minify a specific bundle.
public static void RegisterBundles(BundleCollection _bundles)
{
_bundles.Add(new ScriptBundle("~/bundles/toNotMinify").Include(
"~/Scripts/xxxxxx.js"
));
_bundles.Add(new ScriptBundle("~/bundles/toMinify").Include(
"~/Scripts/yyyyy.js"
));
etc..
这是在我的包配置类的基本布局。我想在其中找到让我所有的捆绑缩小的,从第一个分开的方式。这可能吗?到目前为止,我已经找到了实现类似的东西唯一的办法就是在全球范围内关闭缩小。
This is the basic layout in my bundle config class. I want to find a way in which to have all of my bundles minified, apart from the first one. Is this possible? So far the only solution I have found to achieve something similar is to turn off minification globally.
推荐答案
您有几个选项,您可以用<$ C $取代你的 ScriptBundle
的使用C>捆绑在这个例子:
You have a couple of options, you can either replace your use of ScriptBundle
with Bundle
as in this example:
_bundles.Add(new Bundle("~/bundles/toNotMinify").Include(
"~/Scripts/xxxxxx.js"
));
..或者你可以禁用所有的转换在新创建的捆绑,像这样:
.. or you could disable all transformations on a newly created bundle, like so:
var noMinify = new ScriptBundle("~/bundles/toNotMinify").Include(
"~/Scripts/xxxxxx.js"
);
noMinify.Transforms.Clear();
_bundles.Add(noMinify);
显然,第一解决方案是多prettier:)
Obviously the first solution is much prettier :)
这篇关于ASP.Net MVC包和缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!