发布网站不会更新我的 CSS 包 [英] Publishing a website is not updating my CSS bundles

查看:19
本文介绍了发布网站不会更新我的 CSS 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在发布模式下从 Visual Studio 运行我的代码并检查捆绑的样式表时,我可以看到我对该捆绑包中 css 文件的更新.但是,当我将网站发布到服务器或本地计算机时,样式表中的更改没有通过.捆绑的样式表仍然是旧的.

我尝试了 IIS 重置、干净的构建/重建、从 IIS 文件夹中删除所有文件并重新发布.

如果这有什么不同,我将使用 LESS.

我的捆绑配置:

bundles.Add(new StyleBundle("~/bundles/requiredStyles").Include("~/Content/Style/Libs/bootstrap.min.css","~/Content/Style/Libs/font-awesome.min.css","~/Content/Style/Globals/application.css","/Content/Style/Libs/muliDropdown.css","~/Content/Style/Libs/smoothDivScroll.min.css",~/Content/Style/Libs/jasny-bootstrap.min.css"));

我正在通过访问 http://www.mywebsite.com/bundles/requiredStyles 检查捆绑的 css

所以我对 application.css 进行了更改,如果我在 Visual Studio 中点击播放(在发布模式下),这很好,但是当我发布到本地 IIS 时,我的更改不再存在.

解决方案

如果您在与未缩小的文件相同的目录中有一个缩小版本的 css 文件,就会发生这种情况.

例如,如果您有以下文件:

<前>~/内容/bootstrap.css~/Content/bootstrap.min.css

在您的目录中,并在您的包中注册bootstrap.css"文件,优化器将在发布期间首先尝试使用bootstrap.min.css"文件.如果你只更新了bootstrap.css"文件而没有更新bootstrap.min.css"文件,你会从bootstrap.min.css"中得到旧样式.您可以通过删除bootstrap.min.css"文件或更新它来解决此问题.

这不会在调试版本中发生,因为如果您的编译设置为使用以下进行调试,它不会拉出缩小的文件:

<编译调试=真"/><!-- 为清楚起见,删除了行.--></system.web>

您还可以通过以下方式禁用优化来覆盖 web.config 设置:

<前>BundleTable.EnableOptimizations = false;

这将进入您的 BundleConfig.cs 文件.

When I run my code from Visual Studio in release mode, and check the bundled style sheet, I can see my updates to the css files in that bundle. However when I publish the website to the server or my local machine, my changes in the style sheets have not come through. The bundled style sheet is still the old one.

I have tried an IIS reset, a clean build/rebuild, deleted all files from the IIS folder and re-published.

I am using LESS if that makes any difference.

My bundle config:

bundles.Add(new StyleBundle("~/bundles/requiredStyles").Include(
    "~/Content/Style/Libs/bootstrap.min.css",
    "~/Content/Style/Libs/font-awesome.min.css",
    "~/Content/Style/Globals/application.css",
    "/Content/Style/Libs/muliDropdown.css",
    "~/Content/Style/Libs/smoothDivScroll.min.css",
    "~/Content/Style/Libs/jasny-bootstrap.min.css"
));

I'm checking the bundled css by visiting http://www.mywebsite.com/bundles/requiredStyles

So I made a change in application.css which is fine if I hit play in visual studio (in release mode), but when I publish to my local IIS, my change is no longer there.

解决方案

This can happen if you have a minified version of a css file in the same directory as your unminified file.

For example, if you have the following files:


    ~/Content/bootstrap.css
    ~/Content/bootstrap.min.css

in your directory, and you register the "bootstrap.css" file in your bundle, the optimizer will first attempt to use the "bootstrap.min.css" file during publish. If you only updated the "bootstrap.css" file and did not update the "bootstrap.min.css" file, you will get the old styles from "bootstrap.min.css". You can fix this problem by deleting the "bootstrap.min.css" file or by updating it.

This does not happen in a debug build because it does not pull the minified files if your compilation is set for debug using the following:

<system.web>
    <compilation debug="true" />
    <!-- Lines removed for clarity. -->
</system.web>

You can also overwrite the web.config setting by disabling the optimizations via:


    BundleTable.EnableOptimizations = false;

This would go inside your BundleConfig.cs file.

这篇关于发布网站不会更新我的 CSS 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆