fix: do not publish manifest.json to static files folder.
This commit is contained in:
1 parent
5c81ed18b2
commit
27623a4e93
4 files changed
+16
-18
No files matched your search
@@ -4,29 +4,24 @@ using System.Text.Json;
|
||||
|
||||
namespace WebApplication1;
|
||||
|
||||
#if DEBUG
|
||||
public class ViteHelper(IOptions<JsonOptions> options)
|
||||
{
|
||||
#else
|
||||
public class ViteHelper(IWebHostEnvironment env, IOptions<JsonOptions> options)
|
||||
{
|
||||
readonly string rootPath = env.WebRootPath ?? Path.Combine(AppContext.BaseDirectory, "wwwroot");
|
||||
#endif
|
||||
readonly JsonSerializerOptions jsonOptions = options.Value.JsonSerializerOptions;
|
||||
|
||||
public Task<string> RenderAsync(string pathBase, string templatePath, string entryScript, Dictionary<string, string> stringTokens = null)
|
||||
public Task<string> RenderAsync(string pathBase, string template, string entryScript, Dictionary<string, string> stringTokens = null)
|
||||
{
|
||||
return RenderInternalAsync(pathBase, templatePath, entryScript, null, stringTokens);
|
||||
return RenderInternalAsync(pathBase, template, entryScript, null, stringTokens);
|
||||
}
|
||||
|
||||
public Task<string> RenderAsync<T>(string pathBase, string templatePath, string entryScript, T serverData = default, Dictionary<string, string> stringTokens = null)
|
||||
public Task<string> RenderAsync<T>(string pathBase, string template, string entryScript, T serverData = default, Dictionary<string, string> stringTokens = null)
|
||||
{
|
||||
return RenderInternalAsync(pathBase, templatePath, entryScript, serverData, stringTokens);
|
||||
return RenderInternalAsync(pathBase, template, entryScript, serverData, stringTokens);
|
||||
}
|
||||
|
||||
async Task<string> RenderInternalAsync(string pathBase, string templatePath, string entryScript, object serverData = null, Dictionary<string, string> stringTokens = null)
|
||||
async Task<string> RenderInternalAsync(string pathBase, string template, string entryScript, object serverData = null, Dictionary<string, string> stringTokens = null)
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, templatePath);
|
||||
var templateFolder = Path.Combine(AppContext.BaseDirectory, "Templates");
|
||||
var path = Path.Combine(templateFolder, template);
|
||||
var html = await File.ReadAllTextAsync(path);
|
||||
|
||||
if (stringTokens is not null)
|
||||
@@ -47,7 +42,7 @@ public class ViteHelper(IWebHostEnvironment env, IOptions<JsonOptions> options)
|
||||
<script type="module" src="http://localhost:5173/{entryScript}"></script>
|
||||
""";
|
||||
#else
|
||||
var manifestPath = Path.Combine(rootPath, "dist", ".vite", "manifest.json");
|
||||
var manifestPath = Path.Combine(templateFolder, "manifest.json");
|
||||
var manifestJson = await File.ReadAllTextAsync(manifestPath);
|
||||
using var manifest = JsonDocument.Parse(manifestJson);
|
||||
|
||||
|
||||
Reference in new issue
Block a user