【问题标题】:.NET core BundlerMinifier wrong order of files.NET 核心 BundlerMinifier 文件顺序错误
【发布时间】:2019-01-22 05:59:30
【问题描述】:

我正在为 .NET core 2.1 使用 BundlerMinifier,但我无法设置正确的捆绑文件顺序。

我在wwwroot/js/Lib/ 中有以下文件:

1.jquery.min.js
2.jquery.ui.min.js
3.server.js

打包后,这些文件在 site.js 文件中按指定顺序排序:

2.jquery.ui.min.js
3.server.js
1.jquery.min.js

页面不加载,因为 jquery ui 在 jquery 之前加载。 我在文档中没有找到任何解决方案。我错过了什么吗?

这是我的 bundleconfig.json 文件:

[
  {
    "outputFileName": "wwwroot/js/site-lib.min.js",
    "inputFiles": [
      "wwwroot/js/Lib/"
    ],
    // Optionally specify minification options
    "minify": {
      "enabled": false,
      "renameLocals": true
    }
  }
]

【问题讨论】:

标签: c# .net-core bundling-and-minification


【解决方案1】:

我在 BundlerMinifier 及其读取文件的顺序方面遇到了类似的问题。我的解决方案是删除旧的 bundle.js 和 bundleconfig.json 并重新捆绑所有内容。我所做的不同之处在于我从捆绑包中排除(在我的情况下为 jquery-3.3.1.js)并捆绑了其他所有东西。之后,我首先包含了 jQuery-3.3.1.js,然后是 bundle.js。

<script src="~/js/jquery-3.3.1.js"></script
<script src="~/js/bundle.js"></script>

希望这会有所帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-21
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    • 2017-02-03
    • 1970-01-01
    • 2021-10-27
    • 2019-06-26
    相关资源
    最近更新 更多