如何配置MVC的风格捆绑销售订单? [英] How do I configure MVC's style bundling order?

查看:142
本文介绍了如何配置MVC的风格捆绑销售订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的web应用程序是使用大图标使用jQuery的用户界面和设置的jqGrid。结果
为了便于维护更改CSS的jQuery升级的用户界面或jqGrid的我有一个单独的CSS文件,其中我有一堆覆盖时,以适应更大的图标。

My web app is using a large icon set with jquery-ui and jqgrid.
In order to easily maintain the changes to the CSS to accommodate the larger icons when upgrading jquery-ui or jqgrid I have a separate CSS file where I have a bunch of overrides.

你可以想象这个覆盖文件的必须的包含了jQuery的UI样式和jqGrid的样式表后。

As you can imagine this override file MUST be included after the jquery-ui stylesheet and the jqgrid style sheet.

我把我所有的样式表成束像这样

I put all my stylesheets into a bundle like so

bundles.Add(new StyleBundle("~/Content/dark-hive/allstyles").Include(
    "~/Content/dark-hive/jquery-ui-1.8.23.custom.css",
    "~/Content/ui.jqgrid.css",
    "~/Content/jquery-ui-fixes.css",
    "~/Content/icons.css",
    "~/Content/site.css"));

但所呈现像这样!

But it is being rendered like so!

<link href="/Content/dark-hive/jquery-ui-1.8.23.custom.css" rel="stylesheet"/>
<link href="/Content/jquery-ui-fixes.css" rel="stylesheet"/>
<link href="/Content/ui.jqgrid.css" rel="stylesheet"/>
<link href="/Content/icons.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>

我如何配置我的包按正确的顺序来呈现?

How can I configure my bundle to render in the correct order?

更新结果
好吧,这是愚蠢的,但它的工作。

Update
Ok, this is dumb but it worked.

不管我做什么文件总是渲染不正确。所以我尝试了一些愚蠢和添加的jQuery-UI-fixes.css第一和jQuery-UI-1.8.23.custom.css最后。

No matter what I did the files would always render incorrectly. So I tried something stupid and added jquery-ui-fixes.css first and jquery-ui-1.8.23.custom.css last.

突然,我的订单是

<link href="/Content/jquery-ui-fixes.css" rel="stylesheet"/>
<link href="/Content/dark-hive/jquery-ui-1.8.23.custom.css" rel="stylesheet"/>
<link href="/Content/ui.jqgrid.css" rel="stylesheet"/>
<link href="/Content/icons.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>

我重新命名的JavaScript文件jqueryuifixes.css现在它的顺序是在较低的js文件preserved。

I renamed my javascript file to jqueryuifixes.css and now it's order is preserved in the lower js files.

我在想,如果一个样式表有 - 在名称中它得到优先的第一出于某种原因,这是为了保持与其他文件用 - 它

I'm thinking that if a stylesheet has a - in the name it gets prioritized first for some reason and it's order is maintained with other files with a - in it.

如果任何人都可以解释这一点我会向他们的检查。

If anyone can explain this I'll give them the check.

推荐答案

如果您包括的每个文件,包会尊重您的订单...

If you include each file individually, the bundle will respect your order...

var bundle = new Bundle("~/Content/dark-hive/allstyles", new StyleBundle());           
bundle.Include("~/Content/dark-hive/jquery-ui-1.8.23.custom.css");
bundle.Include("~/Content/ui.jqgrid.css");
bundle.Include("~/Content/jquery-ui-fixes.css");
bundle.Include("~/Content/icons.css");
bundle.Include("~/Content/site.css");
bundles.Add(bundle);

更新

即使使用明令,你会发现有一个相当方便的内置顺序来排序专门首批命名的文件超过所有其他系统。为了彻底清除了这一点,你可以使用:

Even using explicit order, you'll find that there is a rather handy built-in ordering system that orders specifically named files first over all others. To completely clear this out, you can use:

bundles.FileSetOrderList.Clear();

你还可以使用添加自己的自定义排序:

And you can add your own custom ordering using:

BundleFileSetOrdering ordering = new BundleFileSetOrdering("My Order");
ordering.Files.Add("jquery.js");

bundles.FileSetOrderList.Clear();
bundles.FileSetOrderList.Add(ordering);

从本质上讲,有一个将获得投入一定的顺序不在列表中的任何文件之前文件的海量内置列表 - 但这些选项让您掌握控制权

Essentially, there is a massive built-in list of files that will get put in a certain order before any file that isn't in the list - but these options let you take control.

这篇关于如何配置MVC的风格捆绑销售订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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