css js bundle

来源:互联网 发布:生物医药上市知乎 编辑:程序博客网 时间:2024/06/16 20:12
------------- Layout.cshtml ------------- 
<!DOCTYPE html>


<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Title</title>
    
    @this.Html.Partial("BundleStylesFile")
    @this.RenderSection("Styles", required: false)
</head>
<body>
html code

    @this.Html.Partial("BundleScriptsFile")
    @this.RenderSection("Scripts", required: false)
    
    <script>
        ...
    </script>
</body>
</html>


------------- BundleStylesFile.cshtml ------------- 
<environment names="@EnvironmentName.Development">
    <link rel="stylesheet" href="~/css/bootstrap/bootstrap.css" asp-append-version="true" />
    ...
</environment>
<environment names="@EnvironmentName.Staging,@EnvironmentName.Production">
    <link rel="stylesheet" href="~/css/bootstrap/bootstrap.min.css" asp-append-version="true" />
    ...
</environment>
------------- BundleScriptsFile.cshtml ------------- 
<environment names="@EnvironmentName.Development">
    <script src="~/js/bootstrap/bootstrap.js" asp-append-version="true"></script>
    ...
</environment>
<environment names="@EnvironmentName.Staging,@EnvironmentName.Production">
    <script src="~/js/bootstrap/bootstrap.min.js" asp-append-version="true"></script>
    ...
</environment>
原创粉丝点击