asp.net core 2.0 压缩静态资源
新建的Core MVC项目自带bundleconfig.json文件,于是理所当然的照猫画虎,把输入输出的文件配置好,
{
"outputFileName": "wwwroot/css/site.min.css",
"inputFiles": [
"wwwroot/css/style.css",
"wwwroot/css/element-ui.css"
]
}
再到页面上引用。
<environment include="Development">
<link href="~/css/element-ui.css" rel="stylesheet" />
<link href="~/css/style.css" rel="stylesheet" />
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
发现并没有什么卵用,找来找去,网上的答案都是说路径不对之类的问题,无果,
直接看官方资料,https://docs.microsoft.com/zh-cn/aspnet/core/client-side/bundling-and-minification?tabs=visual-studio%2Caspnetcore2x 要先用nuget安装一下BuildBundlerMinifier
Install-Package BuildBundlerMinifier -Version 2.6.375
然后重新生成一下,搞定。

浙公网安备 33010602011771号