Use Bower package version numbers in Razor views for CDN support

ⅰ亾dé卋堺 提交于 2019-12-23 08:49:52

问题


I am using Bower in Visual Studio 2017 to install packages such as Bootstrap and jQuery.

In my views I am referencing the same libraries using a CDN like so:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css"
          asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.css"
          asp-fallback-test-class="glyphicon"
          asp-fallback-test-property="visibility"
          asp-fallback-test-value="hidden" />

If I change the version of Bootstrap in Bower from 3.3.7 to something else, I then have to remember to go into the Razor view and change 3.3.7 to the updated version number.

Should I use Gulp to read the bower.json file and automatically generate a Razor view with the correct Boostrap version number or is there an easier way to ensure Bower and my Razor files are kept in sync?


回答1:


Better create a bundle with all your javascript. Bundling and Minification with ASP.Net MVC

When you bower update, during runtime, bundling will automatically change the JS bundle so that your client will get the latest version.



来源:https://stackoverflow.com/questions/46713286/use-bower-package-version-numbers-in-razor-views-for-cdn-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!