我有 2 个 css 文件。他们两个都是所有页面,除了其中一个是左边语言的修复程序,它将存在于选择左文化的权利时,并且否则不会在它们中。
布局文件中的当前定义:
<environment names="Development">
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
bundleconfig.json:
{
"outputFileName": "wwwroot/css/site.min.css",
// An array of relative input file paths. Globbing patterns supported
"inputFiles": [
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
// Optionally generate .map file
"sourceMap": false
}
有什么方法可以在需要时将其包含在捆绑中吗?我不想单独包含它。
我解决了这个问题。
在 bundleconfig.json 中,我选择创建 2 个不同的缩小 css,一个带有 rtl 补丁,一个没有它:
[
{
"outputFileName": "wwwroot/css/site.min.css",
// An array of relative input file paths. Globbing patterns supported
"inputFiles": [
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/css/sitertl.min.css",
// An array of relative input file paths. Globbing patterns supported
"inputFiles": [
"wwwroot/css/site.css",
"wwwroot/css/rtl.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
// Optionally generate .map file
"sourceMap": false
}
]
在布局中,我添加了这样的条件:
<environment names="Development">
<link rel="stylesheet" href="~/css/site.css" />
@if (CultureInfo.CurrentUICulture.Name.ToLower() == "fa-ir")
{ <link href="~/css/rtl.css" rel="stylesheet" />}
</environment>
<environment names="Staging,Production">
@if(CultureInfo.CurrentUICulture.Name.ToLower()=="fa-ir"){
<link rel="stylesheet" href="~/css/sitertl.min.css" asp-append-version="true" />}
else{
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
}
</environment>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句