mirror of https://github.com/abpframework/abp.git
23 changed files with 192 additions and 42 deletions
@ -0,0 +1,24 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<AssemblyName>Volo.Abp.Minify</AssemblyName> |
||||
|
<PackageId>Volo.Abp.Minify</PackageId> |
||||
|
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Volo.Abp.Core\Volo.Abp.Core.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="NUglify" Version="1.5.13" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.Minify |
||||
|
{ |
||||
|
public class AbpMinifyModule : AbpModule |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.Minify.Html |
||||
|
{ |
||||
|
public interface IHtmlMinifier : IMinifier |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -1,4 +1,4 @@ |
|||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification |
namespace Volo.Abp.Minify |
||||
{ |
{ |
||||
public interface IMinifier |
public interface IMinifier |
||||
{ |
{ |
||||
@ -1,7 +1,7 @@ |
|||||
using NUglify; |
using NUglify; |
||||
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles; |
using Volo.Abp.Minify.Styles; |
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify |
namespace Volo.Abp.Minify.NUglify |
||||
{ |
{ |
||||
public class NUglifyCssMinifier : NUglifyMinifierBase, ICssMinifier |
public class NUglifyCssMinifier : NUglifyMinifierBase, ICssMinifier |
||||
{ |
{ |
||||
@ -0,0 +1,13 @@ |
|||||
|
using NUglify; |
||||
|
using Volo.Abp.Minify.Html; |
||||
|
|
||||
|
namespace Volo.Abp.Minify.NUglify |
||||
|
{ |
||||
|
public class NUglifyHtmlMinifier : NUglifyMinifierBase, IHtmlMinifier |
||||
|
{ |
||||
|
protected override UglifyResult UglifySource(string source, string fileName) |
||||
|
{ |
||||
|
return Uglify.Html(source, sourceFileName: fileName); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,7 @@ |
|||||
using NUglify; |
using NUglify; |
||||
using NUglify.JavaScript; |
using Volo.Abp.Minify.Scripts; |
||||
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify |
namespace Volo.Abp.Minify.NUglify |
||||
{ |
{ |
||||
public class NUglifyJavascriptMinifier : NUglifyMinifierBase, IJavascriptMinifier |
public class NUglifyJavascriptMinifier : NUglifyMinifierBase, IJavascriptMinifier |
||||
{ |
{ |
||||
@ -1,4 +1,4 @@ |
|||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts |
namespace Volo.Abp.Minify.Scripts |
||||
{ |
{ |
||||
public interface IJavascriptMinifier : IMinifier |
public interface IJavascriptMinifier : IMinifier |
||||
{ |
{ |
||||
@ -1,4 +1,4 @@ |
|||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles |
namespace Volo.Abp.Minify.Styles |
||||
{ |
{ |
||||
public interface ICssMinifier : IMinifier |
public interface ICssMinifier : IMinifier |
||||
{ |
{ |
||||
@ -1,26 +0,0 @@ |
|||||
using Shouldly; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify |
|
||||
{ |
|
||||
public class NUglifyJavascriptMinifier_Tests : AbpAspNetCoreMvcUiTestBase |
|
||||
{ |
|
||||
private readonly NUglifyJavascriptMinifier _nUglifyJavascriptMinifier; |
|
||||
|
|
||||
public NUglifyJavascriptMinifier_Tests() |
|
||||
{ |
|
||||
_nUglifyJavascriptMinifier = GetRequiredService<NUglifyJavascriptMinifier>(); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void Should_Minify_Simple_Code() |
|
||||
{ |
|
||||
const string source = "var x = 5; var y = 6;"; |
|
||||
|
|
||||
var minified = _nUglifyJavascriptMinifier.Minify(source); |
|
||||
|
|
||||
minified.Length.ShouldBeGreaterThan(0); |
|
||||
minified.Length.ShouldBeLessThan(source.Length); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,16 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\common.test.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp3.0</TargetFramework> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\Volo.Abp.Minify\Volo.Abp.Minify.csproj" /> |
||||
|
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" /> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,11 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Volo.Abp.Minify |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpMinifyModule), |
||||
|
typeof(AbpTestBaseModule))] |
||||
|
public class AbpMinifyTestModule : AbpModule |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using Shouldly; |
||||
|
using Volo.Abp.Minify.Styles; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.Minify.NUglify |
||||
|
{ |
||||
|
public class CssMinifier_Tests : AbpIntegratedTest<AbpMinifyModule> |
||||
|
{ |
||||
|
private readonly ICssMinifier _cssMinifier; |
||||
|
|
||||
|
public CssMinifier_Tests() |
||||
|
{ |
||||
|
_cssMinifier = GetRequiredService<ICssMinifier>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Minify_Simple_Code() |
||||
|
{ |
||||
|
const string source = "div { color: #FFF; }"; |
||||
|
|
||||
|
var minified = _cssMinifier.Minify(source); |
||||
|
|
||||
|
minified.Length.ShouldBeGreaterThan(0); |
||||
|
minified.Length.ShouldBeLessThan(source.Length); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using Shouldly; |
||||
|
using Volo.Abp.Minify.Html; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.Minify.NUglify |
||||
|
{ |
||||
|
public class HtmlMinifier_Tests : AbpIntegratedTest<AbpMinifyModule> |
||||
|
{ |
||||
|
private readonly IHtmlMinifier _htmlMinifier; |
||||
|
|
||||
|
public HtmlMinifier_Tests() |
||||
|
{ |
||||
|
_htmlMinifier = GetRequiredService<IHtmlMinifier>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Minify_Simple_Code() |
||||
|
{ |
||||
|
const string source = "<div> <p>This is <em> a text </em></p> </div>"; |
||||
|
|
||||
|
var minified = _htmlMinifier.Minify(source); |
||||
|
|
||||
|
minified.Length.ShouldBeGreaterThan(0); |
||||
|
minified.Length.ShouldBeLessThan(source.Length); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using Shouldly; |
||||
|
using Volo.Abp.Minify.Scripts; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Abp.Minify.NUglify |
||||
|
{ |
||||
|
public class JavascriptMinifier_Tests : AbpIntegratedTest<AbpMinifyModule> |
||||
|
{ |
||||
|
private readonly IJavascriptMinifier _javascriptMinifier; |
||||
|
|
||||
|
public JavascriptMinifier_Tests() |
||||
|
{ |
||||
|
_javascriptMinifier = GetRequiredService<IJavascriptMinifier>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Minify_Simple_Code() |
||||
|
{ |
||||
|
const string source = "var x = 5; var y = 6;"; |
||||
|
|
||||
|
var minified = _javascriptMinifier.Minify(source); |
||||
|
|
||||
|
minified.Length.ShouldBeGreaterThan(0); |
||||
|
minified.Length.ShouldBeLessThan(source.Length); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue