脚本包未在调试中呈现单个文件 [英] Script bundles not rendering individual files in debug
问题描述
我定义了两个脚本包:
bundles.Add(new ScriptBundle("~/scripts/common").Include(
"~/Scripts/jquery-1.11.1.js",
"~/Scripts/jquery-ui-1.10.4.custom.min.js",
"~/Scripts/jquery.validate.js"));
bundles.Add(new ScriptBundle("~/scripts/sectionCommon").Include(
"~/Scripts/A.js",
"~/Scripts/B.js",
"~/Scripts/C.js"));
我的主版面设计页面上有一套:
I have one set on my master layout page:
@Scripts.Render("~/scripts/common")
在我使用它的页面的一部分上设置了一个:
And one set on a subset of my pages where it is used:
@Scripts.Render("Scripts/sectionCommon")
到目前为止,一切都很好,并且可行.
So far so good and this works.
当我使用调试编译运行网站时,第一个捆绑包中的JS文件会作为每个文件的单独脚本链接呈现到标记中,而第二个捆绑包仍保留为一个缩小的捆绑包:
When I run my site using debug compilation, the JS files from the first bundle are rendered to the markup as individual script links per file, whereas the second bundle remains as a single minified bundle:
<script src="/siteRoot/Scripts/jquery-1.11.1.js"></script>
<script src="/siteRoot/Scripts/jquery-ui-1.10.4.custom.min.js"></script>
<script src="/siteRoot/Scripts/jquery.validate.js"></script>
<script src="/siteRoot/Scripts/sectionCommon"></script>
有人知道为什么会这样吗?调试时有点痛苦.
Does anybody have any idea why this might be happening? Bit of a pain while debugging.
推荐答案
在我编写问题时想出了这一点.以为我会回答,以防万一这咬人.两者之间的区别在于使用tilda来获取网站的相对网址:
Figured this out while I was writing the question. Thought I would answer it in case this bites anybody else. The difference between the two was using the tilda to get a site relative url:
@Scripts.Render("~/scripts/common")
@Scripts.Render("Scripts/sectionCommon")
这两个脚本均按预期呈现了脚本,但是只有最上面的一个(使用站点相对URL)才在调试中呈现了各个脚本引用.
Both of these render out the script as intended, but only the top one (using the site relative URL) was rendering out the individual script references in debug.
这篇关于脚本包未在调试中呈现单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!