Webpack plugin to use git branch, hash and tag as substitutions for file names
npm install git-rev-webpack-plugin   
Webpack plugin for using git branch, hash (from the last commit) and tag as substitutions in output.filename and output.chunkFilename.
Install it
``bash`
npm install --save-dev git-rev-webpack-plugin
Add the plugin to your webpack config. For example:
`js
const GitRevPlugin = require('git-rev-webpack-plugin');
module.exports = {
plugins: [
new GitRevPlugin(),
],
output: {
filename: '[name]-[git-branch]-[git-tag]-[git-hash].js',
},
};
`
Alternatively you can save the instance to re-use it:
`js
const GitRevPlugin = require('git-rev-webpack-plugin');
const gitRevPlugin = new GitRevPlugin();
module.exports = {
plugins: [
gitRevPlugin,
new webpack.DefinePlugin({
GITHASH: JSON.stringify(gitRevPlugin.hash()),
}),
],
};
`
You can customize the commands and the path.
- branchCommand: The git command to get the branch. rev-parse --abbrev-ref HEAD
Defaults to: hashCommand
- : The git command to get the commit short hash. rev-parse --short HEAD
Defaults to: tagCommand
- : The git command to get the latest tag. describe --abbrev=0 —tags
Defaults to: path
- : The path to the project if not the current cwd.
- branch(): Get the branchhash(long)
- : Get the hashtag()`: Get the tag
-
This is based on git-revision-webpack-plugin.
MIT