我用 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
,我已经稍微修改了它以适应网站的需要。当我发布它时,更改不会出现在 bundle 文件中。这是否意味着 bootstrap 是从 Bootstrap 服务器加载而不是我的项目中加载的?
bundles.Add(new StyleBundle("~/Content/cssmain").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/ilightbox.css",
"~/Content/bannerscollection_zoominout.css"));
我也尝试使用网络应用程序进行代码压缩,但我的更改没有生效,文件似乎也没有被压缩。
感谢任何帮助。
ScriptBundle
来处理脚本和StyleBundle
来处理CSS。 - Shaiju T'.IncludeDirectory("~/js/path", "*.js")
,那么BundleConfig是否仍然知道要使用.min.js文件而不是直接的.js文件? - user5986440