我正在尝试按照微软的建议使用https://github.com/ligershark/WebOptimizer来捆绑和最小化我的 js 文件,因此按照说明进行操作,我的startup.cs 中有以下内容:
app.UseWebOptimizer();
app.UseStaticFiles();
Run Code Online (Sandbox Code Playgroud)
在我的服务配置(startup.cs)中:
services.AddWebOptimizer(pipeline =>
{
pipeline.AddJavaScriptBundle("/js/site.js", // I have tried using MinifyJsFiles (without the use content root) instead of AddJavaScriptBundle
"/lib/jquery-ui-1.13.1.custom/jquery-ui.js",
"/js/auto-complete.js")
.UseContentRoot();
pipeline.MinifyJsFiles(); // I have tried with and without this line
});
Run Code Online (Sandbox Code Playgroud)
在我的 _layout 中:
<script src="~/js/site.js"></script>
Run Code Online (Sandbox Code Playgroud)
但每当我浏览该页面时,当它尝试加载 site.js 时,我都会在网络选项卡中收到 404 错误
我是否错过了什么?所有文件都位于网站 wwwroot 文件夹中的正确位置
ASP.NET Core 5 MVC 应用程序在 Debian Linux 中使用 Weboptimizer ( https://github.com/ligershark/WebOptimizer )。
在startUp.cs中我有:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddWebOptimizer();
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseWebOptimizer();
...
}
Run Code Online (Sandbox Code Playgroud)
syslog 包含大量信息消息,例如
4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:#033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware][1000]
4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:请求已开始 '/css/siteerp.css' 4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:#033[40m# 033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetBuilder][1001]
4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:从内存缓存响应“/css/siteerp.css”
4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:#033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware][1000]
4 月 18 日 09:12:26 …
asp.net-core-mvc .net-core kestrel-http-server asp.net-core weboptimizer