Asp.net
縮小失敗。返回未縮小的內容
我已經使用 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,16): run-time error CSS1062: Expected semicolon or closing curly-brace, found ':' (1680,1): run-time error CSS1019: Unexpected token, found '@keyframes' (1682,5): run-time error CSS1062: Expected semicolon or closing curly-brace, found '50%' (1685,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes' (1687,5): run-time error CSS1062: Expected semicolon or closing curly-brace, 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 */在嘗試更正一些錯誤並再次發布後,錯誤看起來是一樣的。
最奇怪的部分是
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)添加到與未縮小版同目錄的項目中。這會提示捆綁程序使用現有的縮小文件,而不是嘗試(並且失敗)縮小 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"));
