简体   繁体   中英

Versioning in javascript

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM