6

I'm using grunt to build a javascript/angularjs project in the following order:

clean copy > uglify > cssmin.

Now if I change a js file I'd always have to manually add a version increment at the end of the script tag, so that the browser can detect the changes.

<script src="/js/myscript?v123"></script>

Question: how can I automate this process using grunt? If I run the "grunt" command, only files that changed compared to the last run should get a version increment. So that the browser can reuse the cached files as much as possible.

membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

2

I know short answers are not OK (not enough rep to comment), but you might want to checkout grunt-asset-cachebuster. I haven't tried it myself but there are plenty of examples in their npm page.

Also checkout this answer about grunt-newer

Community
  • 1
  • 1
Murat Ozgul
  • 11,193
  • 6
  • 29
  • 32
  • The plugin adds the timestamp to every file on compilation. I only want to add it on files that changed comparing to the last compilation. Apart from that it looks promising. – membersound Dec 30 '15 at 18:59
  • I have found a similar question. Checkout this answer: http://stackoverflow.com/a/19722900/2620998 – Murat Ozgul Dec 31 '15 at 03:22