Versioning in javascript

623 Views Asked by At

I have multiple javascript files that are bundled and minified in one file "bundle-min.js" and is linked in one of my html page. Now I want to introduce versioning in those js files. Means when I change any of my js file, I want my bundle file version to be updated. I have found gulp-version-append but I am not sure whether it will help me or not. Also I don't want to update the reference link of bundle-min.js in my html file again and again. I want my html page to get the latest version it self somehow. Is this possible and what's the best approach? Any help?

1

There are 1 best solutions below

2
On

There are plenty of modules available for this. it depends on your module loader.

Webpack

https://www.npmjs.com/package/webpack-version-file-plugin https://www.npmjs.com/package/versioning-webpack-plugin

or you can use define plugin for this

https://webpack.js.org/plugins/define-plugin/

Refer
How can I inject a build number with webpack?