Implemented css bundling

This commit is contained in:
2024-12-10 16:28:11 +01:00
parent 64b20e26ac
commit 150a18cc0b
4 changed files with 175 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;
using Microsoft.Extensions.Primitives;
using MoonCore.Helpers;
namespace Moonlight.ApiServer.Helpers;
public class BundleAssetFileProvider : IFileProvider
{
public IDirectoryContents GetDirectoryContents(string subpath)
=> NotFoundDirectoryContents.Singleton;
public IFileInfo GetFileInfo(string subpath)
{
if(subpath != "/css/bundle.css")
return new NotFoundFileInfo(subpath);
var physicalPath = PathBuilder.File("storage", "tmp", "bundle.css");
if(!File.Exists(physicalPath))
return new NotFoundFileInfo(subpath);
return new PhysicalFileInfo(new FileInfo(physicalPath));
}
public IChangeToken Watch(string filter)
=> NullChangeToken.Singleton;
}