微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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);
    }

原文地址:https://www.jb51.cc/aspnet/251678.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐