build-git-version-webpack-plugin
v0.0.12
Published
A webpack plugin, add git info version.json to dist
Downloads
21
Readme
build-git-version-webpack-plugin
A webpack plugin, add git info version.json to dist.
Usage
Install
npm install --save-dev build-git-version-webpack-plugin
Config
Use in Webpack
// webpack.config.js
const { BuildGitVersionWebpackPlugin } = require("build-git-version-webpack-plugin");
module.exports = {
plugins: [
new BuildGitVersionWebpackPlugin(),
]
}
Use in Vue 2
// vue.config.js
const { BuildGitVersionWebpackPlugin } = require("build-git-version-webpack-plugin");
module.exports = {
configureWebpack: {
plugins: [
new BuildGitVersionWebpackPlugin()
]
}
}
or
// vue.config.js
const { BuildGitVersionWebpackPlugin } = require("build-git-version-webpack-plugin");
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.plugins = [
...config.plugins,
new BuildGitVersionWebpackPlugin()
]
}
}
}
Use in Vue 3 & Vite & Rollup
recommend rollup-plugin-build-git-version
Use in React
- eject, and config in webpack
- override, @craco/craco or react-app-rewired
Result
{
"build": {
"time": ""
},
"git": {
"branch": "",
"commit": {
"id": "",
"time": "",
"message": "",
"author": {
"name": "",
"email": ""
}
}
}
}