我在 ASP.Net MVC 5 项目中看到捆绑的奇怪行为。当我明确声明 BundleConfig.cs 文件中的所有文件时,我的项目工作得很好,如下所示:
bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/app/app.js",
"~/app/config.js",
"~/app/dir1/file1.js",
"~/app/dir1/subdir1/file2.js",
.....
但是,如果我切换到使用IncludeDirectory
相反,开发期间的脚本路径(BundleTable.EnableOptimizations = false
)不完整。这是我所看到的:
bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/app/app.js",
"~/app/config.js")
.IncludeDirectory("~/app/dir1", "*.js", true)
Chrome 在尝试获取时向我显示 404file2.js
。捆绑系统将以下内容添加到我的布局页面:
<script src="/app/app.js"></script>
<script src="/app/config.js"></script>
<script src="/app/dir1/file1.js"></script>
<script src="/app/dir1/file2.js"></script>
通往的路径file2.js
是错的。它省略了subdir1
路径的一部分。我在这里错过了什么吗?