What are the mechanics of producing bundled js and css files with master pages?

笑着哭i 提交于 2019-12-11 18:09:40

问题


I have a .NET Core project in which the master page _Layout.cshtml page references site wide style and js files:

<link rel="stylesheet" href="~/css/site.css" />
<script src="~/js/site.js" asp-append-version="true"></script>

The Index.cshtml page, which utilizes the above master page, references page specific style and js files:

<link type="text/css" rel="stylesheet" href="~/css/landing.css">    
<script src="~/js/landing.js" asp-append-version="true"></script>

And then Contact.cshtml and About.cshtml also have page specific css and js files.

What is the correct method to bundle the site wide files with page specific files? Should I avoid referencing anything the in the master page and simply reference the bundled file in each page's .cshtml?


回答1:


You reference in your Master Page all scripts and Style Sheets you share across pages. For instance, you could reference only jquery.

You reference in your pages scripts and styles that are used specific on that pages.

It sounds simple like that.



来源:https://stackoverflow.com/questions/50010001/what-are-the-mechanics-of-producing-bundled-js-and-css-files-with-master-pages

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