【问题标题】:StyleBundle not Minifying the CSS files , but it only Bundles the files where it is not minifyingStyleBundle 不缩小 CSS 文件,但它只捆绑不缩小的文件
【发布时间】:2018-04-14 11:23:16
【问题描述】:

我不了解 ASP.NET,但我尝试了一些博客并添加了 dll 文件以缩小 Microsoft.AspNet.Web.Optimization 和 WebGrease dll 文件。 我正在尝试缩小 CSS 文件,但是当我调试并看到它时,我看不到它的缩小,但它只是捆绑在一起

我的类文件

using System.Web.Optimization;
using Umbraco.Core;

namespace MySolution.helpers
{
public class CustomEventHandler : IApplicationEventHandler
 {
        public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) 
        { }
        public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) 
        { }
        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            RegisterStyles(BundleTable.Bundles);
            RegisterJavascript(BundleTable.Bundles);
        }
        private static void RegisterStyles(BundleCollection bundles)
        {
            bundles.Add(new StyleBundle("~/bundle/styles.css").Include(
                    "~/css/carousel.css" , "~/css/menu.css" , "~/css/blog.css" , "~/css/general.css"
                ) );  

                bundles.Add(new StyleBundle("~/bundle/ultradata-styles.css").Include(
                    "~/css/ultradata-styles.css"
                ) );       

        BundleTable.EnableOptimizations = true;


        }
        private static void RegisterJavascript(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundle/javascript.js").Include(
                    "~/scripts/*.js"
                )
            );
        }
    }
}

在浏览器中文件没有被缩小

web config debug 已经是 false

 <compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.6.2" numRecompilesBeforeAppRestart="50">

谁能帮帮我我错过了什么

还有 umbraco 中的 CMS 我这样称呼

   @using System.Web.Optimization
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
    Layout = null;
}

<!doctype html>
<html>
    <head>

        <title>@Umbraco.Field("pageName")</title>
        <meta charset="utf-8">
        <meta content="IE=edge" http-equiv="X-UA-Compatible">
        <meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
        <meta name="description" content="@Umbraco.Field("metaDescription")">
        <meta name="keywords" content="@Umbraco.Field("metaKeywords")">
        <meta name="format-detection" content="telephone=no">   

        <link rel="stylesheet" href="~/css/socialiconstyle.css" />
        <link rel="stylesheet" href="~/css/bootstap/css/bootstrap3.css" />
        <link rel="stylesheet" type="text/css" href="/css/iconfont.css">
         @Styles.Render("~/bundle/styles.css" , "~/bundle/ultradata-styles.css")

【问题讨论】:

    标签: asp.net asp.net-mvc-4 asp.net-mvc-3 razor umbraco7


    【解决方案1】:

    您是否在 web.config 文件中将 /bundle 路径添加到 Umbraco 的保留路径中:

    <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/bundle" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 2015-12-08
      • 2016-01-31
      相关资源
      最近更新 更多