Pet*_*ete 11 bundling-and-minification asp.net-core .net-5 weboptimizer
我正在尝试按照微软的建议使用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 文件夹中的正确位置
验证这些:
您的文件应该位于 wwwroot 目录内的某个位置(如果使用默认配置)
您的文件应使用“Build Action = Content”(csproj 中不应有任何内容)。
当你写:
pipeline.AddSomethingBundle();
Run Code Online (Sandbox Code Playgroud)
文件wwwroot/main.css位于 url 处/main.css。
当你写:
pipeline.AddSomethingBundle("/site.css", "site.css");
Run Code Online (Sandbox Code Playgroud)
它将需要一个文件位于 location wwwroot/site.css。
| 归档时间: |
|
| 查看次数: |
4232 次 |
| 最近记录: |