Manipulate Dependencies during build

I am using Webpack as bundler. Just wanted to check how can I an append branch name to the npm custom package at build time.

Something like:

“dependencies”: {
@fi-uk/fi-framework”: “latest-branch-name”,

If there is any npm plugin or webpack plugin that can help or something through preinstall hook I need to achieve?

Thanks in advance.