Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

asp.net - Ordering of Files within a bundle - What are the known libraries?

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.

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

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...