diff --git a/samples/BundleTransformer.Sample.AspNet45.Mvc4/BundleTransformer.Configuration.xsd b/samples/BundleTransformer.Sample.AspNet45.Mvc4/BundleTransformer.Configuration.xsd index d84e69162..42d4933b4 100644 --- a/samples/BundleTransformer.Sample.AspNet45.Mvc4/BundleTransformer.Configuration.xsd +++ b/samples/BundleTransformer.Sample.AspNet45.Mvc4/BundleTransformer.Configuration.xsd @@ -1367,9 +1367,20 @@ if (condition) { - Number of spaces per indent level when in MultipleLines output mode - - + Number of spaces or tabs per indent level when in `MultipleLines` output mode + + + + + Indent type when in `MultipleLines` output mode + + + + + + + + Column position at which the line will be broken at the next available opportunity diff --git a/samples/BundleTransformer.Sample.AspNet45.Mvc4/Web.config b/samples/BundleTransformer.Sample.AspNet45.Mvc4/Web.config index dbd78539b..61e1232a3 100644 --- a/samples/BundleTransformer.Sample.AspNet45.Mvc4/Web.config +++ b/samples/BundleTransformer.Sample.AspNet45.Mvc4/Web.config @@ -241,15 +241,17 @@ false BundleTransformer.ConfigurationIntelliSense adds a IntelliSense support during editing of the `bundleTransformer` configuration section in the `Web.config` file. - Updated definitions for configuration settings of NUglify CSS minifier. + Updated definitions for configuration settings of NUglify minifiers. Copyright © 2012-2020 Andrey Taritsyn en-US BundleTransformer Web.config IntelliSense diff --git a/src/BundleTransformer.ConfigurationIntelliSense/readme.txt b/src/BundleTransformer.ConfigurationIntelliSense/readme.txt index d9f019d0e..a0caf6602 100644 --- a/src/BundleTransformer.ConfigurationIntelliSense/readme.txt +++ b/src/BundleTransformer.ConfigurationIntelliSense/readme.txt @@ -18,7 +18,7 @@ ============= RELEASE NOTES ============= - Updated definitions for configuration settings of NUglify CSS minifier. + Updated definitions for configuration settings of NUglify minifiers. ============= DOCUMENTATION diff --git a/src/BundleTransformer.NUglify/BundleTransformer.NUglify.csproj b/src/BundleTransformer.NUglify/BundleTransformer.NUglify.csproj index 04df2b98d..9818619f2 100644 --- a/src/BundleTransformer.NUglify/BundleTransformer.NUglify.csproj +++ b/src/BundleTransformer.NUglify/BundleTransformer.NUglify.csproj @@ -11,7 +11,8 @@ BundleTransformer.NUglify contains two minifier-adapters: `NUglifyCssMinifier` (for minification of CSS code) and `NUglifyJsMinifier` (for minification of JS code). These adapters perform minification by using the NUglify (https://github.com/trullock/NUglify). https://raw.githubusercontent.com/Taritsyn/BundleTransformer/master/images/icons/128/BundleTransformer_NUglify_Logo_128x128.png BundleTransformer;System.Web.Optimization;IBundleTransform;ASP.NET;CSS;JavaScript;JS;Bundling;Minification;Minifier;Minify;Obfuscation;NUglify - Added support of the NUglify version 1.9.9. + 1. Added support of the NUglify version 1.10.0; +2. In configuration settings of minifiers was added one new property - `IndentType` (default `Space`). @@ -22,7 +23,7 @@ - + diff --git a/src/BundleTransformer.NUglify/Configuration/MinifierSettingsBase.cs b/src/BundleTransformer.NUglify/Configuration/MinifierSettingsBase.cs index 72ef35294..6446b4aea 100644 --- a/src/BundleTransformer.NUglify/Configuration/MinifierSettingsBase.cs +++ b/src/BundleTransformer.NUglify/Configuration/MinifierSettingsBase.cs @@ -53,7 +53,7 @@ public string IgnoreErrorList } /// - /// Gets or sets a number of spaces per indent level when in + /// Gets or sets a number of spaces or tabs per indent level when in /// MultipleLines output mode /// [ConfigurationProperty("indentSize", DefaultValue = 4)] @@ -63,6 +63,16 @@ public int IndentSize set { this["indentSize"] = value; } } + /// + /// Gets or sets a indent type when in MultipleLines output mode + /// + [ConfigurationProperty("indentType", DefaultValue = IndentType.Space)] + public IndentType IndentType + { + get { return (IndentType)this["indentType"]; } + set { this["indentType"] = value; } + } + /// /// Gets or sets a column position at which the line /// will be broken at the next available opportunity diff --git a/src/BundleTransformer.NUglify/IndentType.cs b/src/BundleTransformer.NUglify/IndentType.cs new file mode 100644 index 000000000..6da8f356b --- /dev/null +++ b/src/BundleTransformer.NUglify/IndentType.cs @@ -0,0 +1,11 @@ +namespace BundleTransformer.NUglify +{ + /// + /// Indent types + /// + public enum IndentType + { + Space, + Tab + } +} \ No newline at end of file diff --git a/src/BundleTransformer.NUglify/Minifiers/NUglifyCssMinifier.cs b/src/BundleTransformer.NUglify/Minifiers/NUglifyCssMinifier.cs index de1403932..668a9d3e8 100644 --- a/src/BundleTransformer.NUglify/Minifiers/NUglifyCssMinifier.cs +++ b/src/BundleTransformer.NUglify/Minifiers/NUglifyCssMinifier.cs @@ -111,18 +111,35 @@ public override string IgnoreErrorList } /// - /// Gets or sets number of spaces per indent level when in + /// Gets or sets number of spaces or tabs per indent level when in /// MultipleLines output mode /// public override int IndentSize { get { - return _cssParserConfiguration.IndentSize; + return _cssParserConfiguration.Indent.Length; } set { - _cssParserConfiguration.IndentSize = value; + _cssParserConfiguration.Indent = GenerateIndentString( + GetIndentType(_cssParserConfiguration.Indent), value); + } + } + + /// + /// Gets or sets a indent type when in MultipleLines output mode + /// + public override IndentType IndentType + { + get + { + return GetIndentType(_cssParserConfiguration.Indent); + } + set + { + _cssParserConfiguration.Indent = GenerateIndentString( + value, _cssParserConfiguration.Indent.Length); } } diff --git a/src/BundleTransformer.NUglify/Minifiers/NUglifyJsMinifier.cs b/src/BundleTransformer.NUglify/Minifiers/NUglifyJsMinifier.cs index d6e310286..ebeb59734 100644 --- a/src/BundleTransformer.NUglify/Minifiers/NUglifyJsMinifier.cs +++ b/src/BundleTransformer.NUglify/Minifiers/NUglifyJsMinifier.cs @@ -119,18 +119,35 @@ public override string IgnoreErrorList } /// - /// Gets or sets number of spaces per indent level when in + /// Gets or sets number of spaces or tabs per indent level when in /// MultipleLines output mode /// public override int IndentSize { get { - return _jsParserConfiguration.IndentSize; + return _jsParserConfiguration.Indent.Length; } set { - _jsParserConfiguration.IndentSize = value; + _jsParserConfiguration.Indent = GenerateIndentString( + GetIndentType(_jsParserConfiguration.Indent), value); + } + } + + /// + /// Gets or sets a indent type when in MultipleLines output mode + /// + public override IndentType IndentType + { + get + { + return GetIndentType(_jsParserConfiguration.Indent); + } + set + { + _jsParserConfiguration.Indent = GenerateIndentString( + value, _jsParserConfiguration.Indent.Length); } } diff --git a/src/BundleTransformer.NUglify/Minifiers/NUglifyMinifierBase.cs b/src/BundleTransformer.NUglify/Minifiers/NUglifyMinifierBase.cs index b1ba6f579..3d5ab5a27 100644 --- a/src/BundleTransformer.NUglify/Minifiers/NUglifyMinifierBase.cs +++ b/src/BundleTransformer.NUglify/Minifiers/NUglifyMinifierBase.cs @@ -46,11 +46,16 @@ public abstract class NUglifyMinifierBase : IMinifier public abstract string IgnoreErrorList { get; set; } /// - /// Gets or sets a number of spaces per indent level when in + /// Gets or sets a number of spaces or tabs per indent level when in /// MultipleLines output mode /// public abstract int IndentSize { get; set; } + /// + /// Gets or sets a indent type when in MultipleLines output mode + /// + public abstract IndentType IndentType { get; set; } + /// /// Gets or sets the column position at which the line /// will be broken at the next available opportunity @@ -133,6 +138,27 @@ internal static string FormatContextError(UglifyError error) return errorMessage; } + protected static IndentType GetIndentType(string indent) + { + IndentType indentType = IndentType.Space; + + if (!string.IsNullOrEmpty(indent)) + { + char firstCharacter = indent[0]; + indentType = firstCharacter == '\t' ? IndentType.Tab : IndentType.Space; + } + + return indentType; + } + + protected static string GenerateIndentString(IndentType type, int width) + { + char character = type == IndentType.Tab ? '\t' : ' '; + string indent = new string(character, width); + + return indent; + } + /// /// Maps a common settings /// @@ -146,6 +172,7 @@ protected static void MapCommonSettings(NUglifyMinifierBase minifier, minifier.IgnoreAllErrors = commonMinifierSettings.IgnoreAllErrors; minifier.IgnoreErrorList = commonMinifierSettings.IgnoreErrorList; minifier.IndentSize = commonMinifierSettings.IndentSize; + minifier.IndentType = commonMinifierSettings.IndentType; minifier.LineBreakThreshold = commonMinifierSettings.LineBreakThreshold; minifier.OutputMode = commonMinifierSettings.OutputMode; minifier.PreprocessorDefineList = commonMinifierSettings.PreprocessorDefineList; diff --git a/src/BundleTransformer.NUglify/readme.txt b/src/BundleTransformer.NUglify/readme.txt index 08379c24e..29df6e717 100644 --- a/src/BundleTransformer.NUglify/readme.txt +++ b/src/BundleTransformer.NUglify/readme.txt @@ -19,7 +19,9 @@ ============= RELEASE NOTES ============= - Added support of the NUglify version 1.9.9. + 1. Added support of the NUglify version 1.10.0; + 2. In configuration settings of minifiers was added one new property - + `IndentType` (default `Space`). ==================== POST-INSTALL ACTIONS