我已经使我的第一个网站使用MVC 5在本地机器上工作正常,但是当我发布到服务器的一些css没有正确加载.
/* Minification Failed. Returning unminified contents. (80,1): run-time error CSS1019: Unexpected token,found '@import' (80,9): run-time error CSS1019: Unexpected token,found 'url('../Content/dark-skin/skin.css')' (671,16): run-time error CSS1062: Expected semicolon or closing curly-brace,found ':' (1288,found ':' (1680,found '@keyframes' (1682,5): run-time error CSS1062: Expected semicolon or closing curly-brace,found '50%' (1685,found '@-webkit-keyframes' (1687,found '50%' */ /* NUGET: BEGIN LICENSE TEXT * * Microsoft grants you the right to use these script files for the sole * purpose of either: (i) interacting through your browser with the Microsoft * website or online service,subject to the applicable licensing or use * terms; or (ii) using the files as included with a Microsoft product subject * to that product's license terms. Microsoft reserves all other rights to the * files not expressly granted by Microsoft,whether by implication,estoppel * or otherwise. The notices and licenses below are for informational purposes only. * * NUGET: END LICENSE TEXT */ /*! * Bootstrap v3.0.0 * * Copyright 2013 Twitter,Inc * Licensed under the Apache License v2.0 * http://www.apache.org/licenses/LICENSE-2.0 * * Designed and built with all the love in the world by @mdo and @fat. *//*! normalize.css v2.1.0 | MIT License | git.io/normalize */
我知道编译器正在尝试最小化css文件,但是没有这样做.我尝试纠正这些错误,但是在纠正了一些错误后,再次发布错误看起来是一样的,就像没有选择我的更改.
最简单的事情是使用bootstrap.css文件,我对网站的目的稍作修改.发布时,更改不在包文件中. Bootstrap服务器是否有可能不是我的项目?
bundles.Add(new StyleBundle("~/Content/cssmain").Include( "~/Content/bootstrap.css","~/Content/site.css","~/Content/ilightBox.css","~/Content/bannerscollection_zoominout.css"));
我也尝试使用Web应用程序自己做细化,但是我的更改不可见,文件看起来不是很细致.
任何帮助是赞赏
解决方法
我通过做两件事情解决了捆绑bootstrap.css的问题:
>将bootstrap.css首先包含在包中.问题中的代码示例已经这样做了,但我没有.
>将官方的最新版本(bootstrap.min.css)添加到与未最终版本相同的目录中的项目中.这会提示bundler使用现有的minified文件,而不是尝试(和失败)来使bootstrap.css本身缩小.请参阅下面的屏幕截图中的绿色箭头.
请注意,如果您使用特定的主题,请使用主题提供的文件替换bootstrap.css和bootstrap.min.css.以下是我的项目中使用spacelab主题的工作代码:
bundles.Add(new StyleBundle(GetStyleBundlePath("bootstrap")).Include( "~/Content/3rdParty/bootstrap.spacelab.css","~/Content/3rdParty/bootstrap-datepicker.css","~/Content/3rdParty/bootstrap-multiselect.css"));