当EnableOptimizations为true时,CSS包为空

kaq*_*ues 4 bundling-and-minification asp.net-mvc-5

我正在创建一个样式包:

bundles.Add(new StyleBundle("~/content/bundled-styles.css").Include(
    "~/content/flexisel-style.css"));
Run Code Online (Sandbox Code Playgroud)

......在我看来:

@Styles.Render("~/content/bundled-styles.css")
Run Code Online (Sandbox Code Playgroud)

如果我在没有启用优化的情况下查看我的页面(即BundleTable.EnableOptimizations = false;),那么一切正常.我的.css文件被添加到页面没有任何问题,它包含所有样式.

如果我设置BundleTable.EnableOptimizations = true;(不更改任何其他内容),则生成的.css包不包含任何样式.捆绑的.css文件与生成的令牌一起添加到页面中,但是当我从页面源单击.css文件时,它是完全空白的.然后我的页面显然没有任何样式.

附加信息:

  • 我的内容文件夹中没有名为"bundled-styles.css"的文件或文件夹
  • 这是我添加的唯一捆绑包.
  • 我没有收到任何错误(如404)..css文件只是空的.
  • 我正在使用ASP.NET MVC 5.

jer*_*ome 5

我也有这个问题.似乎捆绑者不喜欢名称中的扩展名.一旦我删除了扩展程序,捆绑程序就开始工作了.

您可以尝试执行以下操作.请注意我已经删除了.css两个地方.

删除.css

bundles.Add(new StyleBundle("~/content/bundled-styles").Include(
    "~/content/flexisel-style.css"));
Run Code Online (Sandbox Code Playgroud)
@Styles.Render("~/content/bundled-styles")
Run Code Online (Sandbox Code Playgroud)