Skip to content

Commit

Permalink
1. In BundleTransformer.ConfigurationIntelliSense updated definitions…
Browse files Browse the repository at this point in the history
… for configuration settings of NUglify minifiers;

2. In BundleTransformer.NUglify:
	2.1. Added support of the NUglify version 1.10.0;
	2.2. In configuration settings of minifiers was added one new property - `IndentType` (default `Space`).
  • Loading branch information
Taritsyn committed Nov 12, 2020
1 parent 7538405 commit 0754397
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1367,9 +1367,20 @@ if (condition) {
</xs:attribute>
<xs:attribute name="indentSize" type="xs:int" use="optional" default="4">
<xs:annotation>
<xs:documentation>Number of spaces per indent level when in MultipleLines output mode</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:documentation>Number of spaces or tabs per indent level when in `MultipleLines` output mode</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="indentType" use="optional" default="Space">
<xs:annotation>
<xs:documentation>Indent type when in `MultipleLines` output mode</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="Space" />
<xs:enumeration value="Tab" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="lineBreakThreshold" type="xs:int" use="optional" default="2147482647">
<xs:annotation>
<xs:documentation>Column position at which the line will be broken at the next available opportunity</xs:documentation>
Expand Down
10 changes: 6 additions & 4 deletions samples/BundleTransformer.Sample.AspNet45.Mvc4/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,17 @@
</yui>
<nuglify>
<css allowEmbeddedAspNetBlocks="false" blocksStartOnSameLine="NewLine"
ignoreAllErrors="false" ignoreErrorList="" indentSize="4"
lineBreakThreshold="2147482647" outputMode="SingleLine"
ignoreAllErrors="false" ignoreErrorList=""
indentSize="4" indentType="Space"
lineBreakThreshold="2147482647" outputMode="MultipleLines"
preprocessorDefineList="" termSemicolons="false"
colorNames="Hex" commentMode="Important" decodeEscapes="true"
fixIE8Fonts="true" minifyExpressions="true"
removeEmptyBlocks="true" severity="0" />
<js allowEmbeddedAspNetBlocks="false" blocksStartOnSameLine="NewLine"
ignoreAllErrors="false" ignoreErrorList="" indentSize="4"
lineBreakThreshold="2147482647" outputMode="SingleLine"
ignoreAllErrors="false" ignoreErrorList=""
indentSize="4" indentType="Space"
lineBreakThreshold="2147482647" outputMode="MultipleLines"
preprocessorDefineList="" termSemicolons="false"
alwaysEscapeNonAscii="false" amdSupport="false"
collapseToLiteral="true" constStatementsMozilla="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<repository type="git" url="https://github.com/Taritsyn/BundleTransformer" />
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>BundleTransformer.ConfigurationIntelliSense adds a IntelliSense support during editing of the `bundleTransformer` configuration section in the `Web.config` file.</description>
<releaseNotes>Updated definitions for configuration settings of NUglify CSS minifier.</releaseNotes>
<releaseNotes>Updated definitions for configuration settings of NUglify minifiers.</releaseNotes>
<copyright>Copyright © 2012-2020 Andrey Taritsyn</copyright>
<language>en-US</language>
<tags>BundleTransformer Web.config IntelliSense</tags>
Expand Down
2 changes: 1 addition & 1 deletion src/BundleTransformer.ConfigurationIntelliSense/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
=============
RELEASE NOTES
=============
Updated definitions for configuration settings of NUglify CSS minifier.
Updated definitions for configuration settings of NUglify minifiers.

=============
DOCUMENTATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<Description>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).</Description>
<PackageIconUrl>https://raw.githubusercontent.com/Taritsyn/BundleTransformer/master/images/icons/128/BundleTransformer_NUglify_Logo_128x128.png</PackageIconUrl>
<PackageTags>BundleTransformer;System.Web.Optimization;IBundleTransform;ASP.NET;CSS;JavaScript;JS;Bundling;Minification;Minifier;Minify;Obfuscation;NUglify</PackageTags>
<PackageReleaseNotes>Added support of the NUglify version 1.9.9.</PackageReleaseNotes>
<PackageReleaseNotes>1. Added support of the NUglify version 1.10.0;
2. In configuration settings of minifiers was added one new property - `IndentType` (default `Space`).</PackageReleaseNotes>
</PropertyGroup>

<Import Project="../../build/common.props" />
Expand All @@ -22,7 +23,7 @@
<Reference Include="System.configuration" Pack="false" />

<PackageReference Include="AdvancedStringBuilder" Version="0.1.0" />
<PackageReference Include="NUglify" Version="1.9.9" />
<PackageReference Include="NUglify" Version="1.10.0" />

<ProjectReference Include="../BundleTransformer.Core/BundleTransformer.Core.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public string IgnoreErrorList
}

/// <summary>
/// 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
/// <code>MultipleLines</code> output mode
/// </summary>
[ConfigurationProperty("indentSize", DefaultValue = 4)]
Expand All @@ -63,6 +63,16 @@ public int IndentSize
set { this["indentSize"] = value; }
}

/// <summary>
/// Gets or sets a indent type when in <code>MultipleLines</code> output mode
/// </summary>
[ConfigurationProperty("indentType", DefaultValue = IndentType.Space)]
public IndentType IndentType
{
get { return (IndentType)this["indentType"]; }
set { this["indentType"] = value; }
}

/// <summary>
/// Gets or sets a column position at which the line
/// will be broken at the next available opportunity
Expand Down
11 changes: 11 additions & 0 deletions src/BundleTransformer.NUglify/IndentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BundleTransformer.NUglify
{
/// <summary>
/// Indent types
/// </summary>
public enum IndentType
{
Space,
Tab
}
}
23 changes: 20 additions & 3 deletions src/BundleTransformer.NUglify/Minifiers/NUglifyCssMinifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,35 @@ public override string IgnoreErrorList
}

/// <summary>
/// Gets or sets number of spaces per indent level when in
/// Gets or sets number of spaces or tabs per indent level when in
/// <code>MultipleLines</code> output mode
/// </summary>
public override int IndentSize
{
get
{
return _cssParserConfiguration.IndentSize;
return _cssParserConfiguration.Indent.Length;
}
set
{
_cssParserConfiguration.IndentSize = value;
_cssParserConfiguration.Indent = GenerateIndentString(
GetIndentType(_cssParserConfiguration.Indent), value);
}
}

/// <summary>
/// Gets or sets a indent type when in <code>MultipleLines</code> output mode
/// </summary>
public override IndentType IndentType
{
get
{
return GetIndentType(_cssParserConfiguration.Indent);
}
set
{
_cssParserConfiguration.Indent = GenerateIndentString(
value, _cssParserConfiguration.Indent.Length);
}
}

Expand Down
23 changes: 20 additions & 3 deletions src/BundleTransformer.NUglify/Minifiers/NUglifyJsMinifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,35 @@ public override string IgnoreErrorList
}

/// <summary>
/// Gets or sets number of spaces per indent level when in
/// Gets or sets number of spaces or tabs per indent level when in
/// <code>MultipleLines</code> output mode
/// </summary>
public override int IndentSize
{
get
{
return _jsParserConfiguration.IndentSize;
return _jsParserConfiguration.Indent.Length;
}
set
{
_jsParserConfiguration.IndentSize = value;
_jsParserConfiguration.Indent = GenerateIndentString(
GetIndentType(_jsParserConfiguration.Indent), value);
}
}

/// <summary>
/// Gets or sets a indent type when in <code>MultipleLines</code> output mode
/// </summary>
public override IndentType IndentType
{
get
{
return GetIndentType(_jsParserConfiguration.Indent);
}
set
{
_jsParserConfiguration.Indent = GenerateIndentString(
value, _jsParserConfiguration.Indent.Length);
}
}

Expand Down
29 changes: 28 additions & 1 deletion src/BundleTransformer.NUglify/Minifiers/NUglifyMinifierBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ public abstract class NUglifyMinifierBase : IMinifier
public abstract string IgnoreErrorList { get; set; }

/// <summary>
/// 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
/// <code>MultipleLines</code> output mode
/// </summary>
public abstract int IndentSize { get; set; }

/// <summary>
/// Gets or sets a indent type when in <code>MultipleLines</code> output mode
/// </summary>
public abstract IndentType IndentType { get; set; }

/// <summary>
/// Gets or sets the column position at which the line
/// will be broken at the next available opportunity
Expand Down Expand Up @@ -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;
}

/// <summary>
/// Maps a common settings
/// </summary>
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/BundleTransformer.NUglify/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0754397

Please sign in to comment.