Cel*_*dor 1 c# asp.net-mvc bundles
目前我正在测试捆绑包,我知道有可能使用诸如{version}或之类的外卡*.我不完全确定{version}是为了什么.我认为*像正则表达式需要的一切,会匹配所有的可能性作品:jquery*指一切都像jqueryA,jquery-ui.js等我只是想有可能选择我的JavaScript库,CSS文件,等在下面的无论是开发或生产版本的文件结构:
Content\
css\
bootstrap-theme.css
bootstrap-theme-min.css
bootstrap.css
bootstrap.min.css
the same with Scripts:
Scripts\
jquery-2.1.3.js
jquery-2.1.3.min.js
jquery-ui.js
jquery-ui.min.js
Run Code Online (Sandbox Code Playgroud)
我已经定义了以下捆绑包但我觉得{version}在字符串内部或错误的位置是错误的:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include("~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/bundles/css/Bootstrap").Include("~/Content/css/bootstrap-theme{version}.css"));
bundles.Add(new StyleBundle("~/bundles/css/Bootstrap").Include("~/Content/css/bootstrap{version}.css"));
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/StyleSheet.css"));
Run Code Online (Sandbox Code Playgroud)
我怎么可以指示ASP.NET例如替代bootstrap.css了bootstrap.min.css在应用程序的发布版本.
谢谢!
该{version}有点像一个通配符,但它确实两个额外的事情,这限制了通配符的东西,看起来像一个版本号("1.2.3",例如),它使用它找到的最高版本.这允许您拥有相同脚本的多个版本,并且捆绑器将始终使用最新版本.
例如,如果您有以下内容:
Scripts\
+ jquery-1.10.1.js
+ jquery-1.10.2.js
+ jquery-2.0.0.js
Run Code Online (Sandbox Code Playgroud)
和脚本包如:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js");
Run Code Online (Sandbox Code Playgroud)
然后,~/Scripts/jquery-2.0.0.js将添加到捆绑包中.