mirror of https://github.com/abpframework/abp
parent
d05b83a3f5
commit
2118845a55
@ -1,26 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.Bundling
|
||||
{
|
||||
public class BundleManager : IBundleManager, ITransientDependency
|
||||
{
|
||||
private readonly BundlingOptions _options;
|
||||
|
||||
public BundleManager(IOptions<BundlingOptions> options)
|
||||
{
|
||||
_options = options.Value;
|
||||
}
|
||||
|
||||
public List<string> GetStyleBundleFiles(string bundleName)
|
||||
{
|
||||
return _options.StyleBundles.GetFiles(bundleName);
|
||||
}
|
||||
|
||||
public List<string> GetScriptBundleFiles(string bundleName)
|
||||
{
|
||||
return _options.ScriptBundles.GetFiles(bundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
|
||||
{
|
||||
public class BundleManager : IBundleManager, ISingletonDependency
|
||||
{
|
||||
private readonly BundlingOptions _options;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IBundler _bundler;
|
||||
|
||||
private readonly ConcurrentDictionary<string, string> _cache;
|
||||
|
||||
public BundleManager(
|
||||
IOptions<BundlingOptions> options,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IBundler bundler)
|
||||
{
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_bundler = bundler;
|
||||
_options = options.Value;
|
||||
|
||||
_cache = new ConcurrentDictionary<string, string>();
|
||||
}
|
||||
|
||||
public List<string> GetStyleBundleFiles(string bundleName)
|
||||
{
|
||||
return _options.StyleBundles.GetFiles(bundleName);
|
||||
}
|
||||
|
||||
public List<string> GetScriptBundleFiles(string bundleName)
|
||||
{
|
||||
//if (_hostingEnvironment.IsDevelopment())
|
||||
{
|
||||
return _options.ScriptBundles.GetFiles(bundleName);
|
||||
}
|
||||
|
||||
return new List<string>
|
||||
{
|
||||
_cache.GetOrAdd(
|
||||
"SCRIPT:" + bundleName,
|
||||
() => _bundler.CreateBundle(
|
||||
_options.ScriptBundles.GetFiles(bundleName)
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
|
||||
{
|
||||
public class Bundler : IBundler, ITransientDependency
|
||||
{
|
||||
public Bundler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string CreateBundle(List<string> files)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
namespace Volo.Abp.AspNetCore.Mvc.Bundling
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
|
||||
{
|
||||
public class BundlingOptions
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.Bundling
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
|
||||
{
|
||||
public interface IBundleManager
|
||||
{
|
||||
@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
|
||||
{
|
||||
public interface IBundler
|
||||
{
|
||||
string CreateBundle(List<string> files);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification
|
||||
{
|
||||
public interface IJavascriptMinifier
|
||||
{
|
||||
string Minify(string source, string fileName = null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using NUglify;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify
|
||||
{
|
||||
public class NUglifyException : AbpException
|
||||
{
|
||||
public List<UglifyError> Errors { get; set; }
|
||||
|
||||
public NUglifyException(string message, List<UglifyError> errors)
|
||||
: base(message)
|
||||
{
|
||||
Errors = errors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for serializing.
|
||||
/// </summary>
|
||||
public NUglifyException(SerializationInfo serializationInfo, StreamingContext context)
|
||||
: base(serializationInfo, context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
using NUglify;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify
|
||||
{
|
||||
public class NUglifyJavascriptMinifier : IJavascriptMinifier, ITransientDependency
|
||||
{
|
||||
public string Minify(string source, string fileName = null)
|
||||
{
|
||||
var result = Uglify.Js(source, fileName);
|
||||
CheckErrors(result);
|
||||
return result.Code;
|
||||
}
|
||||
|
||||
private static void CheckErrors(UglifyResult result)
|
||||
{
|
||||
if (result.HasErrors)
|
||||
{
|
||||
throw new NUglifyException(
|
||||
"There are some errors on uglifying the given source code!",
|
||||
result.Errors
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
||||
<AssemblyName>Volo.Abp.AspNetCore.Mvc.UI.Tests</AssemblyName>
|
||||
<PackageId>Volo.Abp.AspNetCore.Mvc.UI.Tests</PackageId>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||
<RootNamespace />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.Mvc.UI\Volo.Abp.AspNetCore.Mvc.UI.csproj" />
|
||||
<ProjectReference Include="..\..\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
|
||||
<ProjectReference Include="..\Volo.Abp.AspNetCore.Tests\Volo.Abp.AspNetCore.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Below ItemGroup and Target tags are added according to https://github.com/aspnet/Hosting/issues/959#issuecomment-286351703 -->
|
||||
|
||||
<!-- Solves Problem#2 (404 when executing service calls hosted in other assemblies) -->
|
||||
<!-- https://github.com/Microsoft/vstest/issues/196.-->
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- https://github.com/NuGet/Home/issues/4412. -->
|
||||
<Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
|
||||
<ItemGroup>
|
||||
<DepsFilePaths Include="$([System.IO.Path]::ChangeExtension('%(_ResolvedProjectReferencePaths.FullPath)', '.deps.json'))" />
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="%(DepsFilePaths.FullPath)" DestinationFolder="$(OutputPath)" Condition="Exists('%(DepsFilePaths.FullPath)')" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in new issue