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

后端 未结 1 1896
我寻月下人不归
我寻月下人不归 2020-12-11 01:53

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.

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-11 02:18

    Its in the doc comments for BundleCollection.AddDefaultFileOrderings:

        /// 
        /// Add default file ordering for common popuular script and style libraries.
        /// 
        /// A collection of  objects to populate with default values.
        /// 
        /// 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 .
        /// 
        /// The default ordering values are as follows:
        /// 
        ///     reset.css
        ///     normalize.css
        ///     jquery.js
        ///     jquery-min.js
        ///     jquery-*
        ///     jquery-ui*
        ///     jquery.ui*
        ///     jquery.unobtrusive*
        ///     jquery.validate*
        ///     modernizr-*
        ///     dojo.*
        ///     mootools-core*
        ///     mootools-*
        ///     prototype.js
        ///     prototype-*
        ///     scriptaculous-*
        ///     ext.js
        ///     ext-*
        /// 
        /// 
        public static void AddDefaultFileOrderings(IList 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);
        }
    

    0 讨论(0)
提交回复
热议问题