如何将以下的BundleConfig.cs转换为BundleConfig.json?我正在将一个.NET 4.6.2项目迁移到NET ASP Core 2,并收到了下面的错误,正在尝试研究。我还尝试阅读微软文档 https://learn.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-2.2&tabs=visual-studio
原始BundleConfig.cs
namespace Test.Web
{
/// <summary>
/// Bundle configs registration common class.
/// </summary>
public class BundleConfig
{
/// <summary>
/// Register Bundles.
/// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
/// </summary>
/// <param name="bundles"></param>
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/misc/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/misc/bootstrap.js",
"~/Scripts/misc/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
}
}
}
尝试的解决方案: 从第三段开始
[
{
"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
},
{
"outputFileName": "~/bundles/jquery",
"inputFiles": [
"\"~/Scripts/jquery/jquery-{version}.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
// Optionally generate .map file
"sourceMap": false
},
收到错误:
Value must match regular expression \.css$
Value must match regular expression \.js$