我試圖爲我的應用程序捆綁腳本和樣式bootstrap。我的調試正在工作但是,當我發佈它時,不要加載腳本和樣式。捆綁MVC4.5發佈後不工作
我添加BundleConfig(BootstrapBundleConfig)
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/js").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-1.10.4.custom.js",
"~/Scripts/jquery-migrate-{version}.js",
"~/Scripts/bootstrap.js",
"~/Scripts/gridmvc.js",
"~/Scripts/gridmvc.lang.fa.js",
"~/Scripts/jquery.validate.js",
"~/scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.validate.unobtrusive-custom-for-bootstrap.js",
"~/scripts/entitypicker.js",
"~/scripts/js-persian-cal.js",
"~/scripts/json2.js",
"~/scripts/bootbox.js",
"~/Scripts/jalali.js",
"~/Scripts/calendar.js",
"~/Scripts/calendar-setup.js",
"~/Scripts/lang/calendar-fa.js"
));
bundles.Add(new StyleBundle("~/content/css").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-responsive.css",
"~/Content/bootstrap-mvc-validation.css",
"~/Content/themes/ui-lightness/jquery-ui.css",
"~/Content/js-persian-cal.css",
"~/Content/entitypicker.css",
"~/Content/gridmvc.css",
"~/Content/aqua/theme.css",
"~/Content/calendar-system.css"
));
}
在_layaout
<link href="@Styles.Url("~/content/css")" rel="stylesheet" />
@Scripts.Render("~/js")
增加註冊這個全球
BootstrapSupport.BootstrapBundleConfig.RegisterBundles(System.Web.Optimization.BundleTable.Bundles);
和設置樣式/腳本但是,當發佈它,打開查看頁面源文件
<link href="/Content/css?v=65vDyivXbF9ucPBBLls9CVnwUcCNass7hOMNUEXbN-I1" rel="stylesheet" />
當打開此文件在第一行出現錯誤。
/* Minification failed. Returning unminified contents.
(962,1): run-time error CSS1019: Unexpected token, found '@charset'
(962,10): run-time error CSS1019: Unexpected token, found '"UTF-8"'
(962,17): run-time error CSS1019: Unexpected token, found ';'
(994,1): run-time error CSS1019: Unexpected token, found '@-webkit-keyframes'
我在谷歌搜索和使用不同的方法,但錯誤沒有解決。
所有樣式添加到一個特殊的路徑(內容/他們/引導),並使用
new StyleBundle("~/content/Them/Bootstrap")
使用
BundleTable.EnableOptimizations = true;
等..
我刪除了'BundleTable.EnableOptimizations'但不起作用。 – Niloo
我從來沒有告訴過你刪除它。 –
我設置了false/true,但不加載樣式/腳本。 – Niloo