示例#1
0
        static void AddBundle(BundleCollection bundles, string bundlePath, string scriptPath)
        {
            bool isJavascript = scriptPath.EndsWith(".js");
            var resolver = new BundleResolver(bundles);

            if (bundles.Any(b => b.Path == bundlePath))
            {
                var bundle = bundles.First(b => b.Path == bundlePath);
                var contents = resolver.GetBundleContents(bundle.Path);

                if (!contents.Any(s => s == scriptPath))
                {
                    //if bundle already exists, include the script path
                    bundle.Include(scriptPath);
                }
            }
            else
            {
                //if bundle not exists, create the bundle and include the script path
                if (isJavascript)
                {
                    bundles.Add(new ScriptBundle(bundlePath).Include(scriptPath));
                }
                else
                {
                    bundles.Add(new StyleBundle(bundlePath).Include(scriptPath, new CssRewriteUrlTransform()));
                }
            }
        }
示例#2
0
        // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bool optimize;

            bool.TryParse(ConfigurationManager.AppSettings["optimize-bundles"], out optimize);
            BundleTable.EnableOptimizations = optimize;
            if (!bundles.Any(x => x.Path == "~/bundles/control-panel/js"))
            {
                var bundle = new ScriptBundle("~/bundles/control-panel/js");
                bundle.Orderer = new AsIsBundleOrderer();
                bundle
                .Include("~/assets-web/panel/js/help-information.js")
                .Include("~/assets-web/panel/js/short-link.js")
                .Include("~/assets/plugins/ladda-bootstrap/spin.min.js")
                .Include("~/assets/plugins/ladda-bootstrap/ladda.min.js")
                .Include("~/assets-web/panel/js/website.js");
                bundles.Add(bundle);
            }
            if (!bundles.Any(x => x.Path == "~/bundles/control-panel/css"))
            {
                var bundle = new StyleBundle("~/bundles/control-panel/css");
                bundle.Orderer = new AsIsBundleOrderer();
                bundle.Include("~/assets-web/panel/css/control-panel.css");
                bundle.Include("~/assets/plugins/ladda-bootstrap/ladda-themeless.min.css");
                bundles.Add(bundle);
            }
            if (!bundles.Any(x => x.Path == "~/bundles/website/css"))
            {
                var bundle = new StyleBundle("~/bundles/website/css");
                bundle.Orderer = new AsIsBundleOrderer();
                bundle
                .Include("~/assets-web/ui/css/style.css")
                .Include("~/assets-web/ui/css/hover.css")
                .Include("~/assets-web/ui/css/button.css")
                .Include("~/assets-web/ui/css/form.css")
                .Include("~/assets-web/ui/css/responsive.css")
                ;
                bundles.Add(bundle);
            }
        }
        public void RegisterBundles_ShouldRegisterRequiredBundles()
        {
            // Arrange
            var bundles = new BundleCollection();

            // Act
            BundleConfig.RegisterBundles(bundles);

            // Assert
            Assert.IsTrue(bundles.Any(x => x.Path == "~/bundles/jquery"));
            Assert.IsTrue(bundles.Any(x => x.Path == "~/bundles/jqueryval"));
            Assert.IsTrue(bundles.Any(x => x.Path == "~/bundles/modernizr"));
            Assert.IsTrue(bundles.Any(x => x.Path == "~/bundles/bootstrap"));
            Assert.IsTrue(bundles.Any(x => x.Path == "~/bundles/bootbox"));
            Assert.IsTrue(bundles.Any(x => x.Path == "~/bundles/toastr"));
            Assert.IsTrue(bundles.Any(x => x.Path == "~/Content/Styles/all"));
        }
示例#4
0
        static void AddBundle(BundleCollection bundles, string bundlePath, string scriptPath)
        {
            bool isJavascript = scriptPath.EndsWith(".js");

            if (bundles.Any(b => b.Path == bundlePath))
            {
                bundles.First(b => b.Path == bundlePath).Include(scriptPath);
            }
            else
            {
                if (isJavascript)
                {
                    bundles.Add(new ScriptBundle(bundlePath).Include(scriptPath));
                }
                else
                {
                    bundles.Add(new StyleBundle(bundlePath).Include(scriptPath, new CssRewriteUrlTransform()));
                }
            }
        }
示例#5
0
 public static bool BundleExists(this BundleCollection bundles, string virtualPath)
 {
     return(bundles.Any(x => x.Path == virtualPath));
 }
        // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                            "~/Scripts/jQuery/jquery-{version}.js"));

            //    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
            //                "~/Scripts/jquery-ui-{version}.js"));

            //    bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
            //                "~/Scripts/jquery.unobtrusive*",
            //                "~/Scripts/jquery.validate*"));

            //    bundles.Add(new ScriptBundle("~/bundles/angular").Include(
            //                "~/Scripts/angular.js",
            //                "~/Scripts/angular-ng-grid.js",
            //                "~/Scripts/angular-resource.js",
            //                "~/Scripts/angular-route.js"));

            //    bundles.Add(new ScriptBundle("~/bundles/app").Include(
            //                "~/Scripts/app/app.js",
            //                "~/Scripts/app/services.js",
            //                "~/Scripts/app/directives.js",
            //                "~/Scripts/app/main.js",
            //                "~/Scripts/app/contact.js",
            //                "~/Scripts/app/about.js",
            //                "~/Scripts/app/demo.js"
            //                ));

            //    // Use the development version of Modernizr to develop with and learn from. Then, when you're
            //    // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            //    bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            //                "~/Scripts/modernizr-*"));

            //    bundles.Add(new StyleBundle("~/Content/bootstrap").Include(
            //        "~/Content/bootstrap.css",
            //        "~/Content/bootstrap-responsive.css"
            //        ));


            //    bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css",
            //        "~/Content/ng-grid.css"));

            //    bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
            //                "~/Content/themes/base/jquery.ui.core.css",
            //                "~/Content/themes/base/jquery.ui.resizable.css",
            //                "~/Content/themes/base/jquery.ui.selectable.css",
            //                "~/Content/themes/base/jquery.ui.accordion.css",
            //                "~/Content/themes/base/jquery.ui.autocomplete.css",
            //                "~/Content/themes/base/jquery.ui.button.css",
            //                "~/Content/themes/base/jquery.ui.dialog.css",
            //                "~/Content/themes/base/jquery.ui.slider.css",
            //                "~/Content/themes/base/jquery.ui.tabs.css",
            //                "~/Content/themes/base/jquery.ui.datepicker.css",
            //                "~/Content/themes/base/jquery.ui.progressbar.css",
            //                "~/Content/themes/base/jquery.ui.theme.css"));

            if (bundles.Any(b => b.Path == "~/Content/LayoutBundleCss") && bundles.Any(b => b.Path == "~/Scripts/LayoutBundleJavascript"))
            {
                return;
            }

            CDNHelper.SetCdnSettingInSession();


            if (string.IsNullOrWhiteSpace(CDNHelper.JavaScriptStaticContentUrl) || string.IsNullOrWhiteSpace(CDNHelper.CssStaticContentUrl))
            {
                bundles.UseCdn = false;
            }
            else
            {
                bundles.UseCdn = true;
            }

            Bundle cssBundle = new StyleBundle("~/Content/LayoutBundleCss", string.Format("{0}/Content/LayoutCss-3.css", CDNHelper.CssStaticContentUrl))
                               .Include("~/Content/LayoutCss-3.css");

            Bundle javascriptBundle = new ScriptBundle("~/Scripts/LayoutBundleJavascript", string.Format("{0}/Scripts/LayoutJavascript.js", CDNHelper.JavaScriptStaticContentUrl))
                                      .Include("~/Scripts/LayoutJavascript.js");

            bundles.Add(cssBundle);
            bundles.Add(javascriptBundle);

            BundleTable.EnableOptimizations = true;
        }