Commits

glav committed 72707f6

Added config to enable/disable .less support

Comments (0)

Files changed (5)

ScriptDependencyExtension/Constants/XmlConstants.cs

 		public const string VersionMonikerQueryStringName = "VersionMonikerQueryStringName";
     	public const string CombineScriptsAttribute = "CombineScripts";
 		public const string MinifyScriptsInReleaseMode = "MinifyCombinedScriptsInReleaseMode";
+		public const string EnableDotLessSupport = "EnableDotLessSupport";
 
         public const string CSSTypeValue = "css";
 		public const string JSTypeValue = "js";

ScriptDependencyExtension/Model/ScriptDependencyContainer.cs

 {
     public class ScriptDependencyContainer
     {
+		public ScriptDependencyContainer()
+		{
+			EnableDotLessSupport = true;
+		}
         public string ReleaseSuffix { get; set; }
         public string DebugSuffix { get; set;  }
 		public string VersionIdentifier { get; set; }
 		public string VersionMonikerQueryStringName { get; set; }
 		public bool ShouldCombineScripts { get; set; }
 		public bool ShouldMinifyScriptsInReleaseMode { get; set; }
+		public bool EnableDotLessSupport { get; set; }
 
         private List<ScriptDependency> _knownDependencies = new List<ScriptDependency>();
         public List<ScriptDependency> Dependencies { get { return _knownDependencies; } }

ScriptDependencyExtension/ScriptDependencyLoader.cs

         	var versionMoniker = rootElement.Attribute(XmlConstants.VersionMonikerQueryStringName);
 			var combineScripts = rootElement.Attribute(XmlConstants.CombineScriptsAttribute);
 			var minifyScripts = rootElement.Attribute(XmlConstants.MinifyScriptsInReleaseMode);
+			var dotLessSupport = rootElement.Attribute(XmlConstants.EnableDotLessSupport);
 
 			_dependencyContainer.VersionIdentifier = scriptVersion !=null ? scriptVersion.Value : "1.0";
             _dependencyContainer.ReleaseSuffix = releaseSuffixEl != null ? releaseSuffixEl.Value : string.Empty;
 			_dependencyContainer.ShouldMinifyScriptsInReleaseMode = minifyScripts != null
 															? (minifyScripts.Value.ToLower() == "true")
 															: false;
+			_dependencyContainer.EnableDotLessSupport = dotLessSupport != null
+															? (dotLessSupport.Value.ToLower() == "true")
+															: false;
 
             ExtractDependencies(dependencies);
         }

ScriptDependencyExtension/ScriptEngine.cs

 
 		public ScriptCache ScriptCache
 		{
-			get { return _scriptCache;  }
+			get { return _scriptCache; }
 		}
 
 		public string RenderDeferredScriptsToBuffer()
 		public void ApplyFiltersToScriptOutput(StringBuilder emittedScript, ScriptType scriptType, ScriptDependencyContainer container)
 		{
 			_filters.ForEach((filter) =>
-			                 	{
-			                 		var filterResult = filter().ProcessScript(emittedScript.ToString(),scriptType, container);
+								{
+									var filterResult = filter().ProcessScript(emittedScript.ToString(), scriptType, container);
 									if (!string.IsNullOrWhiteSpace(filterResult))
 									{
 										emittedScript.Clear();
 										emittedScript.Append(filterResult);
 									}
-			                 	});
+								});
 		}
-		
+
 		private void RegisterFilters()
 		{
-			_filters.Add(() => dotLessFilter.GetDotLessProcessingFilter(_httpContext,_scriptLoader.DependencyContainer));
+			if (_scriptLoader.DependencyContainer.EnableDotLessSupport)
+			{
+				_filters.Add(() => dotLessFilter.GetDotLessProcessingFilter(_httpContext, _scriptLoader.DependencyContainer));
+			}
 			_filters.Add(() => new ScriptMinifierFilter(_httpContext));
 		}
 
 			{
 				if (_scriptLoader.DependencyContainer.ShouldCombineScripts)
 				{
-				    if (!cssCombineList.Contains(dependency.ScriptName))
-				        cssCombineList.Add(dependency.ScriptName);
+					if (!cssCombineList.Contains(dependency.ScriptName))
+						cssCombineList.Add(dependency.ScriptName);
 				}
 				else
 				{
 				{
 					buffer.Append(fullScriptInclude);
 				}
-                _scriptCache.AddToAlreadyRenderedScripts(dependency.ScriptName);
+				_scriptCache.AddToAlreadyRenderedScripts(dependency.ScriptName);
 			}
 		}
 

ScriptDependencyWebsite/ScriptDependencies.xml

 <?xml version="1.0" encoding="utf-8" ?>
 <Dependencies ReleaseSuffix="" DebugSuffix="" VersionIdentifier="1.0" 
               VersionMonikerQueryStringName="v" CombineScripts="true"
-              MinifyCombinedScriptsInReleaseMode="true">
+              MinifyCombinedScriptsInReleaseMode="true" EnableDotLessSupport="true">
 
   <Dependency Name="jQuery-validate-unobtrusive" Type="js">
     <ScriptFile>~/Scripts/jquery.validate.unobtrusive.js</ScriptFile>