什么是已知的图书馆 - 一个包中的文件进行排序? [英] Ordering of Files within a bundle - What are the known libraries?

查看:148
本文介绍了什么是已知的图书馆 - 一个包中的文件进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在捆绑和微小的,我知道,打捆会走动某些已知文件类型的 - 所以这东西像jQuery将被移动到前面。

In Bundling and Minification, I've known that the bundler will move around certain known file types -- so that things like jQuery will be moved to the front.

在默认情况下,当文件被捆绑ASP.NET它们进行排序
  按字母顺序排列第一,就像它们被显示在Solution Explorer。
  然后,他们将被自动转移过来,以便知名图书馆和
  他们的自定义扩展,如jQuery的,MooTools的和Dojo是装
  先天下之忧。
  <一href=\"http://weblogs.asp.net/scottgu/archive/2011/11/27/new-bundling-and-minification-support-asp-net-4-5-series.aspx\">-source

By default, when files are bundled by ASP.NET they are sorted alphabetically first, just like they are shown in Solution Explorer. Then they are automatically shifted around so that known libraries and their custom extensions such as jQuery, MooTools and Dojo are loaded before anything else. -source

但读完这最近的问题后: ASP.NET MVC - 捆绑配置顺序,它展示了如何将文件过得去,即使用户指定的加载顺序的打捆感动,我意识到,我不知道的什么这些已知文件类型,或在 ORDER 他们将被列出。

But after reading this recent question: ASP.NET MVC - Bundle Config order, which shows how a file is getting moved by the bundler even when the user has specified the load order, I realized I didn't know WHAT these known file types are, or the ORDER they will be listed in.

我从来没有见过一个列表解释这一点,并在搜索,我想出了什么。

I've never seen a list explaining this, and in searching, I came up with nothing.

有一个列表中显示了已知文件类型,他们将在呈现的顺序?我认为这是值得的ASP.NET团队应该为开发人员提供一个资源。

Is there a list the shows what the known file types are and the order they will be rendered in? I would think this is something the ASP.NET team should provide developers as a resource.

推荐答案

其在BundleCollection.AddDefaultFileOrderings的文档注释:

Its in the doc comments for BundleCollection.AddDefaultFileOrderings:

    /// <summary>
    /// Add default file ordering for common popuular script and style libraries.
    /// </summary>
    /// <param name="list">A collection of <see cref="BundleFileSetOrdering"/> objects to populate with default values.</param>
    /// <remarks>
    /// The purpose for applying these default file ordering values is to ensure that common libraries such as jquery are always located 
    /// at or close to the top within a bundle. These values can be all removed with <see cref="ResetAll"/>.
    /// 
    /// The default ordering values are as follows:
    /// <list type="bullet">
    ///     <item><description>reset.css</description></item>
    ///     <item><description>normalize.css</description></item>
    ///     <item><description>jquery.js</description></item>
    ///     <item><description>jquery-min.js</description></item>
    ///     <item><description>jquery-*</description></item>
    ///     <item><description>jquery-ui*</description></item>
    ///     <item><description>jquery.ui*</description></item>
    ///     <item><description>jquery.unobtrusive*</description></item>
    ///     <item><description>jquery.validate*</description></item>
    ///     <item><description>modernizr-*</description></item>
    ///     <item><description>dojo.*</description></item>
    ///     <item><description>mootools-core*</description></item>
    ///     <item><description>mootools-*</description></item>
    ///     <item><description>prototype.js</description></item>
    ///     <item><description>prototype-*</description></item>
    ///     <item><description>scriptaculous-*</description></item>
    ///     <item><description>ext.js</description></item>
    ///     <item><description>ext-*</description></item>
    /// </list>
    /// </remarks>
    public static void AddDefaultFileOrderings(IList<BundleFileSetOrdering> list) {
        if (list == null) {
            throw new ArgumentNullException("list");
        }

        BundleFileSetOrdering css = new BundleFileSetOrdering("css");
        css.Files.Add("reset.css");
        css.Files.Add("normalize.css");
        list.Add(css);

        BundleFileSetOrdering jquery = new BundleFileSetOrdering("jquery");
        jquery.Files.Add("jquery.js");
        jquery.Files.Add("jquery-min.js");
        jquery.Files.Add("jquery-*");
        jquery.Files.Add("jquery-ui*");
        jquery.Files.Add("jquery.ui*");
        jquery.Files.Add("jquery.unobtrusive*");
        jquery.Files.Add("jquery.validate*");
        list.Add(jquery);

        BundleFileSetOrdering mod = new BundleFileSetOrdering("modernizr");
        mod.Files.Add("modernizr-*");
        list.Add(mod);

        BundleFileSetOrdering dojo = new BundleFileSetOrdering("dojo");
        dojo.Files.Add("dojo.*");
        list.Add(dojo);

        BundleFileSetOrdering moo = new BundleFileSetOrdering("moo");
        moo.Files.Add("mootools-core*");
        moo.Files.Add("mootools-*");
        list.Add(moo);

        BundleFileSetOrdering proto = new BundleFileSetOrdering("prototype");
        proto.Files.Add("prototype.js");
        proto.Files.Add("prototype-*");
        proto.Files.Add("scriptaculous-*");
        list.Add(proto);

        BundleFileSetOrdering ext = new BundleFileSetOrdering("ext");
        ext.Files.Add("ext.js");
        ext.Files.Add("ext-*");
        list.Add(ext);
    }

这篇关于什么是已知的图书馆 - 一个包中的文件进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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