Left file: appwork-v1_1_0/aspnet-mvc-starter/AspnetMvcStarter/App_Start/BundleConfig.cs  
Right file: appwork-v1_2_0/aspnet-mvc-starter/AspnetMvcStarter/App_Start/BundleConfig.cs  
1 using System.Web.Optimization; = 1 using System.Web.Optimization;
2 using System;   2 using System;
3 using System.Collections.Generic;   3 using System.Collections.Generic;
4 using System.IO;   4 using System.IO;
5 using System.Text.RegularExpressions;   5 using System.Text.RegularExpressions;
6 using Glob; <> 6 using GlobExpressions;
7 using BundleTransformer.Core.Bundles; = 7 using BundleTransformer.Core.Bundles;
8 using BundleTransformer.Core.Orderers;   8 using BundleTransformer.Core.Orderers;
9 using BundleTransformer.Core.Resolvers;   9 using BundleTransformer.Core.Resolvers;
    -+ 10 using System.Web;
10   = 11  
11 namespace AspnetMvcStarter   12 namespace AspnetMvcStarter
12 {   13 {
    -+ 14     public class CssRewriteUrlTransformWrapper : IItemTransform
      15     {
      16         public string Process(string includedVirtualPath, string input)
      17         {
      18             return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input);
      19         }
      20     }
13   = 21  
14     public class BundleConfig   22     public class BundleConfig
15     {   23     {
16         // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862   24         // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
17         public static void RegisterBundles(BundleCollection bundles)   25         public static void RegisterBundles(BundleCollection bundles)
18         {   26         {
19             // bundles.UseCdn = true;   27             // bundles.UseCdn = true;
20             // BundleTable.EnableOptimizations = true;   28             // BundleTable.EnableOptimizations = true;
21     29  
22             // Replace a default bundle resolver in order to the debugging HTTP handler   30             // Replace a default bundle resolver in order to the debugging HTTP handler
23             // can use transformations of the corresponding bundle   31             // can use transformations of the corresponding bundle
24             BundleResolver.Current = new CustomBundleResolver();   32             BundleResolver.Current = new CustomBundleResolver();
25     33  
26             // ------------------------------------------------------------------------------------   34             // ------------------------------------------------------------------------------------
27             // Application assets   35             // Application assets
28             //   36             //
29     37  
30             bundles.Add(SassBundle("~/bundle/css/main").Include("~/Content/main.scss"));   38             bundles.Add(SassBundle("~/bundle/css/main").Include("~/Content/main.scss"));
31             bundles.Add(new ScriptBundle("~/bundle/js/main").Include("~/Scripts/main.js"));   39             bundles.Add(new ScriptBundle("~/bundle/js/main").Include("~/Scripts/main.js"));
32     40  
33             // Bundle jquery-validation-unobtrusive package   41             // Bundle jquery-validation-unobtrusive package
34             bundles.Add(new ScriptBundle("~/bundle/vendor/js/jquery-validation-unobtrusive/jquery-validation-unobtrusive").Include(   42             bundles.Add(new ScriptBundle("~/bundle/vendor/js/jquery-validation-unobtrusive/jquery-validation-unobtrusive").Include(
35                         "~/node_modules/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js"));   43                         "~/node_modules/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js"));
36     44  
37             // ------------------------------------------------------------------------------------   45             // ------------------------------------------------------------------------------------
38             // Core stylesheets   46             // Core stylesheets
39             //   47             //
40     48  
41             bundles.Add(SassBundle("~/bundle/vendor/css/bootstrap").Include("~/Vendor/css/bootstrap.scss"));   49             bundles.Add(SassBundle("~/bundle/vendor/css/bootstrap").Include("~/Vendor/css/bootstrap.scss"));
42             bundles.Add(SassBundle("~/bundle/vendor/css/appwork").Include("~/Vendor/css/appwork.scss"));   50             bundles.Add(SassBundle("~/bundle/vendor/css/appwork").Include("~/Vendor/css/appwork.scss"));
43             bundles.Add(SassBundle("~/bundle/vendor/css/theme-corporate").Include("~/Vendor/css/theme-corporate.scss"));   51             bundles.Add(SassBundle("~/bundle/vendor/css/theme-corporate").Include("~/Vendor/css/theme-corporate.scss"));
44             bundles.Add(SassBundle("~/bundle/vendor/css/colors").Include("~/Vendor/css/colors.scss"));   52             bundles.Add(SassBundle("~/bundle/vendor/css/colors").Include("~/Vendor/css/colors.scss"));
45             bundles.Add(SassBundle("~/bundle/vendor/css/uikit").Include("~/Vendor/css/uikit.scss"));   53             bundles.Add(SassBundle("~/bundle/vendor/css/uikit").Include("~/Vendor/css/uikit.scss"));
46     54  
47             // ------------------------------------------------------------------------------------   55             // ------------------------------------------------------------------------------------
48             // Automatically bundle ~/Vendor/js directory   56             // Automatically bundle ~/Vendor/js directory
49             //   57             //
50     58  
51             // Bundle path: ~/bundle/vendor/js/{filename}   59             // Bundle path: ~/bundle/vendor/js/{filename}
52             foreach (string[] bundleFile in GetVendorBundles("js", "js", "**/*", "js"))   60             foreach (string[] bundleFile in GetVendorBundles("js", "js", "**/*", "js"))
53             {   61             {
54                 bundles.Add(new ScriptBundle(bundleFile[0]).Include(bundleFile[1])); <> 62                 bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1]));
55             } = 63             }
56     64  
57             // ------------------------------------------------------------------------------------   65             // ------------------------------------------------------------------------------------
58             // Automatically bundle ~/Vendor/css/pages directory   66             // Automatically bundle ~/Vendor/css/pages directory
59             //   67             //
60     68  
61             // Bundle path: ~/bundle/vendor/css/pages/{filename}   69             // Bundle path: ~/bundle/vendor/css/pages/{filename}
62             foreach (string[] bundleFile in GetVendorBundles("css\\pages", "css/pages", "**/*", "scss"))   70             foreach (string[] bundleFile in GetVendorBundles("css\\pages", "css/pages", "**/*", "scss"))
63             {   71             {
64                 bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1]));   72                 bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1]));
65             }   73             }
66     74  
67             // ------------------------------------------------------------------------------------   75             // ------------------------------------------------------------------------------------
68             // Automatically bundle ~/Vendor/fonts directory   76             // Automatically bundle ~/Vendor/fonts directory
69             //   77             //
70     78  
71             // Bundle path: ~/bundle/vendor/fonts/{filename}   79             // Bundle path: ~/bundle/vendor/fonts/{filename}
72             foreach (string[] bundleFile in GetVendorBundles("fonts", "fonts", "*", "css"))   80             foreach (string[] bundleFile in GetVendorBundles("fonts", "fonts", "*", "css"))
73             {   81             {
74                 bundles.Add(new StyleBundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransform())); <> 82                 bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransformWrapper()));
75             } = 83             }
76     84  
77             // ------------------------------------------------------------------------------------   85             // ------------------------------------------------------------------------------------
78             // Automatically bundle ~/Vendor/libs directory   86             // Automatically bundle ~/Vendor/libs directory
79             //   87             //
80     88  
81             // Bundle path: ~/bundle/vendor/css/{libdir}/{filename}   89             // Bundle path: ~/bundle/vendor/css/{libdir}/{filename}
82             foreach (string[] bundleFile in GetVendorBundles("libs", "css", "**/*", "scss"))   90             foreach (string[] bundleFile in GetVendorBundles("libs", "css", "**/*", "scss"))
83             {   91             {
84                 if (bundleFile[2] == "true")   92                 if (bundleFile[2] == "true")
85                 {   93                 {
86                     bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransform())); <> 94                     bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransformWrapper()));
87                 } = 95                 }
88                 else   96                 else
89                 {   97                 {
90                     bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1]));   98                     bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1]));
91                 }   99                 }
92             }   100             }
93     101  
94             // Bundle path: ~/bundle/vendor/js/{libdir}/{filename}   102             // Bundle path: ~/bundle/vendor/js/{libdir}/{filename}
95             foreach (string[] bundleFile in GetVendorBundles("libs", "js", "**/*", "js"))   103             foreach (string[] bundleFile in GetVendorBundles("libs", "js", "**/*", "js"))
96             {   104             {
97                 bundles.Add(new ScriptBundle(bundleFile[0]).Include(bundleFile[1])); <> 105                 bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1]));
98             } = 106             }
99     107  
100         }   108         }
101     109  
102         private static Bundle SassBundle(string path)   110         private static Bundle SassBundle(string path)
103         {   111         {
104             return new CustomStyleBundle(path)   112             return new CustomStyleBundle(path)
105             {   113             {
106                 Orderer = new NullOrderer()   114                 Orderer = new NullOrderer()
107             };   115             };
108         }   116         }
109     117  
110         private static string[][] GetVendorBundles(string sourcePath, string bundlePath, string globPattern, string ext)   118         private static string[][] GetVendorBundles(string sourcePath, string bundlePath, string globPattern, string ext)
111         {   119         {
112             // Application root directory path   120             // Application root directory path
113             string APP_PATH = AppDomain.CurrentDomain.BaseDirectory;   121             string APP_PATH = AppDomain.CurrentDomain.BaseDirectory;
114             //   122             //
115     123  
116             DirectoryInfo dirInfo = new DirectoryInfo(APP_PATH + "\\Vendor\\" + sourcePath);   124             DirectoryInfo dirInfo = new DirectoryInfo(APP_PATH + "\\Vendor\\" + sourcePath);
117             IEnumerable<FileInfo> contents = dirInfo.GlobFiles(globPattern + "." + ext);   125             IEnumerable<FileInfo> contents = dirInfo.GlobFiles(globPattern + "." + ext);
118     126  
119             List<string[]> bundles = new List<string[]>();   127             List<string[]> bundles = new List<string[]>();
120     128  
121             Regex normalizeRegex = new Regex("\\\\");   129             Regex normalizeRegex = new Regex("\\\\");
122     130  
123             sourcePath = normalizeRegex.Replace(sourcePath, "/") + "/";   131             sourcePath = normalizeRegex.Replace(sourcePath, "/") + "/";
124     132  
125             Regex pathRegex = new Regex(".*?" + Regex.Escape("/Vendor/" + sourcePath));   133             Regex pathRegex = new Regex(".*?" + Regex.Escape("/Vendor/" + sourcePath));
126             Regex nameRegex = new Regex("\\." + Regex.Escape(ext) + "$");   134             Regex nameRegex = new Regex("\\." + Regex.Escape(ext) + "$");
127     135  
128             Regex urlRewriteTestRegex = new Regex("/(" +   136             Regex urlRewriteTestRegex = new Regex("/(" +
129                     "minicolors/minicolors" + "|" +   137                     "minicolors/minicolors" + "|" +
130                     "blueimp-gallery/gallery-video" + "|" +   138                     "blueimp-gallery/gallery-video" + "|" +
131                     "blueimp-gallery/gallery" + "|" +   139                     "blueimp-gallery/gallery" + "|" +
132                     "jstree/themes/default/style" + "|" +   140                     "jstree/themes/default/style" + "|" +
133                     "jstree/themes/default-dark/style" + "|" +   141                     "jstree/themes/default-dark/style" + "|" +
134                     "photoswipe/photoswipe" +   142                     "photoswipe/photoswipe" +
135                 ")\\.scss$");   143                 ")\\.scss$");
136     144  
137             foreach (FileInfo file in contents)   145             foreach (FileInfo file in contents)
138             {   146             {
139                 string filePath = pathRegex.Replace(normalizeRegex.Replace(file.FullName, "/"), "");   147                 string filePath = pathRegex.Replace(normalizeRegex.Replace(file.FullName, "/"), "");
140                 string relativeBundlePath = "~/bundle/vendor/" + bundlePath + "/" + nameRegex.Replace(filePath, "");   148                 string relativeBundlePath = "~/bundle/vendor/" + bundlePath + "/" + nameRegex.Replace(filePath, "");
141                 string relativeSourcePath = "~/Vendor/" + sourcePath + filePath;   149                 string relativeSourcePath = "~/Vendor/" + sourcePath + filePath;
142                 bool urlRewrite = urlRewriteTestRegex.IsMatch(relativeSourcePath);   150                 bool urlRewrite = urlRewriteTestRegex.IsMatch(relativeSourcePath);
143     151  
144                 bundles.Add(new string[] { relativeBundlePath, relativeSourcePath, urlRewrite ? "true" : "false" });   152                 bundles.Add(new string[] { relativeBundlePath, relativeSourcePath, urlRewrite ? "true" : "false" });
145             }   153             }
146     154  
147             return bundles.ToArray();   155             return bundles.ToArray();
148         }   156         }
149     157  
150     }   158     }
151 }   159 }