asp.net – 包中的文件排序 – 已知的库是什么?

前端之家收集整理的这篇文章主要介绍了asp.net – 包中的文件排序 – 已知的库是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在捆绑和缩小中,我已经知道捆绑器将移动某些已知的文件类型 – 因此像jQuery这样的东西将被移到前面.

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.
07000

但在阅读了最近的一个问题:ASP.NET MVC – Bundle Config order,它显示了即使用户指定了加载顺序,文件如何被捆绑器移动,我意识到我不知道这些已知文件类型是什么,或者它们将是ORDER列于.

我从来没有见过一个解释这个的清单,在搜索中,我什么也没想到.

是否有列表显示已知文件类型是什么以及它们将呈现的顺序?我认为这是ASP.NET团队应该为开发人员提供资源的东西.

解决方法

它在BundleCollection.AddDefaultFileOrderings的doc注释中:
/// <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);
    }

猜你在找的asp.Net相关文章