【问题标题】:How do I automatically, with Grunt, reference the new (minified & concatenated) JavaScript files in HTML?如何使用 Grunt 自动引用 HTML 中的新(缩小和连接)JavaScript 文件?
【发布时间】:2015-07-19 05:11:31
【问题描述】:

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

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

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

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

最终的 html 文件应该是:

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

【问题讨论】:

标签: javascript gruntjs


【解决方案1】:

你可以使用 grunt-processhtml 插件来替换它

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

【讨论】:

    猜你喜欢
    • 2014-02-04
    • 1970-01-01
    • 2013-01-25
    • 1970-01-01
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多