Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

My index.html page looks like this:

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

Using grunt i was able to concat and minify the js files into one file at prod/js/file.min.js. I also have a new index.html page at prod/index.html that is minify.

The problem now is that this new index.html page still reference the old three javascript files and not the new single javascript file. How would I go about changing this in grunt?

final html file should be:

  <html>     
  <script src="js/file.min.js"></script>
  </html>
like image 648
user1742835 Avatar asked Oct 31 '22 23:10

user1742835


1 Answers

You can use grunt-processhtml plugin to replace it

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

like image 105
abs Avatar answered Nov 11 '22 03:11

abs