| using System.Web.Optimization; |
= |
using System.Web.Optimization; |
| using System; |
|
using System; |
| using System.Collections.Generic; |
|
using System.Collections.Generic; |
| using System.IO; |
|
using System.IO; |
| using System.Text.RegularExpressions; |
|
using System.Text.RegularExpressions; |
| using GlobExpressions; |
|
using GlobExpressions; |
| using BundleTransformer.Core.Bundles; |
|
using BundleTransformer.Core.Bundles; |
| using BundleTransformer.Core.Orderers; |
|
using BundleTransformer.Core.Orderers; |
| using BundleTransformer.Core.Resolvers; |
|
using BundleTransformer.Core.Resolvers; |
| using System.Web; |
|
using System.Web; |
| |
|
|
| namespace AspnetMvcStarter |
|
namespace AspnetMvcStarter |
| { |
|
{ |
| public class CssRewriteUrlTransformWrapper : IItemTransform |
|
public class CssRewriteUrlTransformWrapper : IItemTransform |
| { |
|
{ |
| public string Process(string includedVirtualPath, string input) |
|
public string Process(string includedVirtualPath, string input) |
| { |
|
{ |
| return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input); |
|
return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input); |
| } |
|
} |
| } |
|
} |
| |
|
|
| public class BundleConfig |
|
public class BundleConfig |
| { |
|
{ |
| |
|
|
| public static void RegisterBundles(BundleCollection bundles) |
|
public static void RegisterBundles(BundleCollection bundles) |
| { |
|
{ |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| BundleResolver.Current = new CustomBundleResolver(); |
|
BundleResolver.Current = new CustomBundleResolver(); |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| bundles.Add(SassBundle("~/bundle/css/main").Include("~/Content/main.scss")); |
|
bundles.Add(SassBundle("~/bundle/css/main").Include("~/Content/main.scss")); |
| bundles.Add(new ScriptBundle("~/bundle/js/main").Include("~/Scripts/main.js")); |
|
bundles.Add(new ScriptBundle("~/bundle/js/main").Include("~/Scripts/main.js")); |
| |
|
|
| |
|
|
| bundles.Add(new ScriptBundle("~/bundle/vendor/js/jquery-validation-unobtrusive/jquery-validation-unobtrusive").Include( |
<> |
bundles.Add(new ScriptBundle("~/bundle/vendor/js/validate-unobtrusive/validate-unobtrusive").Include( |
| "~/node_modules/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js")); |
= |
"~/node_modules/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js")); |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| bundles.Add(SassBundle("~/bundle/vendor/css/bootstrap").Include("~/Vendor/css/bootstrap.scss")); |
|
bundles.Add(SassBundle("~/bundle/vendor/css/bootstrap").Include("~/Vendor/css/bootstrap.scss")); |
| bundles.Add(SassBundle("~/bundle/vendor/css/appwork").Include("~/Vendor/css/appwork.scss")); |
|
bundles.Add(SassBundle("~/bundle/vendor/css/appwork").Include("~/Vendor/css/appwork.scss")); |
| bundles.Add(SassBundle("~/bundle/vendor/css/theme-corporate").Include("~/Vendor/css/theme-corporate.scss")); |
|
bundles.Add(SassBundle("~/bundle/vendor/css/theme-corporate").Include("~/Vendor/css/theme-corporate.scss")); |
| bundles.Add(SassBundle("~/bundle/vendor/css/colors").Include("~/Vendor/css/colors.scss")); |
|
bundles.Add(SassBundle("~/bundle/vendor/css/colors").Include("~/Vendor/css/colors.scss")); |
| bundles.Add(SassBundle("~/bundle/vendor/css/uikit").Include("~/Vendor/css/uikit.scss")); |
|
bundles.Add(SassBundle("~/bundle/vendor/css/uikit").Include("~/Vendor/css/uikit.scss")); |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| foreach (string[] bundleFile in GetVendorBundles("js", "js", "**/*", "js")) |
|
foreach (string[] bundleFile in GetVendorBundles("js", "js", "**/*", "js")) |
| { |
|
{ |
| bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1])); |
|
bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1])); |
| } |
|
} |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| foreach (string[] bundleFile in GetVendorBundles("css\\pages", "css/pages", "**/*", "scss")) |
|
foreach (string[] bundleFile in GetVendorBundles("css\\pages", "css/pages", "**/*", "scss")) |
| { |
|
{ |
| bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1])); |
|
bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1])); |
| } |
|
} |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| foreach (string[] bundleFile in GetVendorBundles("fonts", "fonts", "*", "css")) |
|
foreach (string[] bundleFile in GetVendorBundles("fonts", "fonts", "*", "css")) |
| { |
|
{ |
| bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransformWrapper())); |
|
bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransformWrapper())); |
| } |
|
} |
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| foreach (string[] bundleFile in GetVendorBundles("libs", "css", "**/*", "scss")) |
|
foreach (string[] bundleFile in GetVendorBundles("libs", "css", "**/*", "scss")) |
| { |
|
{ |
| if (bundleFile[2] == "true") |
|
if (bundleFile[2] == "true") |
| { |
|
{ |
| bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransformWrapper())); |
|
bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1], new CssRewriteUrlTransformWrapper())); |
| } |
|
} |
| else |
|
else |
| { |
|
{ |
| bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1])); |
|
bundles.Add(SassBundle(bundleFile[0]).Include(bundleFile[1])); |
| } |
|
} |
| } |
|
} |
| |
|
|
| |
|
|
| foreach (string[] bundleFile in GetVendorBundles("libs", "js", "**/*", "js")) |
|
foreach (string[] bundleFile in GetVendorBundles("libs", "js", "**/*", "js")) |
| { |
|
{ |
| bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1])); |
|
bundles.Add(new Bundle(bundleFile[0]).Include(bundleFile[1])); |
| } |
|
} |
| |
|
|
| } |
|
} |
| |
|
|
| private static Bundle SassBundle(string path) |
|
private static Bundle SassBundle(string path) |
| { |
|
{ |
| return new CustomStyleBundle(path) |
|
return new CustomStyleBundle(path) |
| { |
|
{ |
| Orderer = new NullOrderer() |
|
Orderer = new NullOrderer() |
| }; |
|
}; |
| } |
|
} |
| |
|
|
| private static string[][] GetVendorBundles(string sourcePath, string bundlePath, string globPattern, string ext) |
|
private static string[][] GetVendorBundles(string sourcePath, string bundlePath, string globPattern, string ext) |
| { |
|
{ |
| |
|
|
| string APP_PATH = AppDomain.CurrentDomain.BaseDirectory; |
|
string APP_PATH = AppDomain.CurrentDomain.BaseDirectory; |
| |
|
|
| |
|
|
| DirectoryInfo dirInfo = new DirectoryInfo(APP_PATH + "\\Vendor\\" + sourcePath); |
|
DirectoryInfo dirInfo = new DirectoryInfo(APP_PATH + "\\Vendor\\" + sourcePath); |
| IEnumerable<FileInfo> contents = dirInfo.GlobFiles(globPattern + "." + ext); |
|
IEnumerable<FileInfo> contents = dirInfo.GlobFiles(globPattern + "." + ext); |
| |
|
|
| List<string[]> bundles = new List<string[]>(); |
|
List<string[]> bundles = new List<string[]>(); |
| |
|
|
| Regex normalizeRegex = new Regex("\\\\"); |
|
Regex normalizeRegex = new Regex("\\\\"); |
| |
|
|
| sourcePath = normalizeRegex.Replace(sourcePath, "/") + "/"; |
|
sourcePath = normalizeRegex.Replace(sourcePath, "/") + "/"; |
| |
|
|
| Regex pathRegex = new Regex(".*?" + Regex.Escape("/Vendor/" + sourcePath)); |
|
Regex pathRegex = new Regex(".*?" + Regex.Escape("/Vendor/" + sourcePath)); |
| Regex nameRegex = new Regex("\\." + Regex.Escape(ext) + "$"); |
|
Regex nameRegex = new Regex("\\." + Regex.Escape(ext) + "$"); |
| |
|
|
| Regex urlRewriteTestRegex = new Regex("/(" + |
|
Regex urlRewriteTestRegex = new Regex("/(" + |
| "minicolors/minicolors" + "|" + |
|
"minicolors/minicolors" + "|" + |
| "blueimp-gallery/gallery-video" + "|" + |
|
"blueimp-gallery/gallery-video" + "|" + |
| "blueimp-gallery/gallery" + "|" + |
|
"blueimp-gallery/gallery" + "|" + |
| "jstree/themes/default/style" + "|" + |
|
"jstree/themes/default/style" + "|" + |
| "jstree/themes/default-dark/style" + "|" + |
|
"jstree/themes/default-dark/style" + "|" + |
| "photoswipe/photoswipe" + |
|
"photoswipe/photoswipe" + |
| ")\\.scss$"); |
|
")\\.scss$"); |
| |
|
|
| foreach (FileInfo file in contents) |
|
foreach (FileInfo file in contents) |
| { |
|
{ |
| string filePath = pathRegex.Replace(normalizeRegex.Replace(file.FullName, "/"), ""); |
|
string filePath = pathRegex.Replace(normalizeRegex.Replace(file.FullName, "/"), ""); |
| string relativeBundlePath = "~/bundle/vendor/" + bundlePath + "/" + nameRegex.Replace(filePath, ""); |
|
string relativeBundlePath = "~/bundle/vendor/" + bundlePath + "/" + nameRegex.Replace(filePath, ""); |
| string relativeSourcePath = "~/Vendor/" + sourcePath + filePath; |
|
string relativeSourcePath = "~/Vendor/" + sourcePath + filePath; |
| bool urlRewrite = urlRewriteTestRegex.IsMatch(relativeSourcePath); |
|
bool urlRewrite = urlRewriteTestRegex.IsMatch(relativeSourcePath); |
| |
|
|
| bundles.Add(new string[] { relativeBundlePath, relativeSourcePath, urlRewrite ? "true" : "false" }); |
|
bundles.Add(new string[] { relativeBundlePath, relativeSourcePath, urlRewrite ? "true" : "false" }); |
| } |
|
} |
| |
|
|
| return bundles.ToArray(); |
|
return bundles.ToArray(); |
| } |
|
} |
| |
|
|
| } |
|
} |
| } |
|
} |