【问题标题】:Bundling js and css in .NET Core在 .NET Core 中捆绑 js 和 css
【发布时间】:2021-01-05 08:09:18
【问题描述】:

有没有办法在没有 node.js(和 gulp)的情况下在 .NET Core Web 应用程序中使用捆绑?

Microsoft 官方文档采用 node/gulp: https://docs.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-3.1

有没有更好/更轻便的方法?

【问题讨论】:

    标签: asp.net asp.net-core web-applications bundling-and-minification


    【解决方案1】:

    安装Bundler & Minifier extension,你会得到一个名为bundleconfig.json的文件,然后这样配置:

    [
      {
        "outputFileName": "wwwroot/js/Production/script.min.js",
        "inputFiles": [
          "wwwroot/lib/somelibrary/lib.js"
        ],
        "minify": {
          "enabled": true,
          "renameLocals": true
        },
        "sourceMap": false
      },
      {
        "outputFileName": "wwwroot/css/Production/style.min.css",
        "inputFiles": [
          "wwwroot/lib/somelibrary/css/style.css",
        ],
        "minify": { "enabled": true }
      },
    ]
    

    您的文件将像配置文件一样在保存时捆绑在一起。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-12
      相关资源
      最近更新 更多