我如何使用 Grunt 自动引用 HTML 中的新(缩小和串联)JavaScript 文件?

How do I automatically, with Grunt, reference the new (minified & concatenated) JavaScript files in HTML?

我的 index.html 页面如下所示:

  <html>     
  <script src="js/file1.js"></script>
  <script src="js/file2.js"></script>
  <script src="js/file2.js"></script>
  </html>

使用 grunt 我能够将 js 文件合并并缩小到 prod/js/file.min.js 处的一个文件中。我在 prod/index.html 也有一个新的 index.html 页面,它是 minify。

现在的问题是这个新的 index.html 页面仍然引用旧的三个 javascript 文件,而不是新的单个 javascript 文件。我将如何在 grunt 中更改它?

最终 html 文件应为:

  <html>     
  <script src="js/file.min.js"></script>
  </html>

可以使用grunt-processhtml插件代替

https://www.npmjs.com/package/grunt-processhtml