webpack 打包插件,向打包目录插入一个version.json,该json包含一些打包版本的git信息

xmf fc2b72ca72 doc: 修改版本号 4 years ago
src 61dbb5c09c 修改branch获取方式 4 years ago
.gitignore 3174b8916d feat: 创建一个生产git commit 信息的webpack plugin 4 years ago
.npmignore 3174b8916d feat: 创建一个生产git commit 信息的webpack plugin 4 years ago
README.md 5325453e1b doc: 更新README说明 4 years ago
package.json fc2b72ca72 doc: 修改版本号 4 years ago

README.md

build-version-webpack-plugin

install

npm install --save-dev build-version-webpack-plugin

use

vue-cli 3

// vue.config.js
const BuildVersionWebpackPlugin = requrie('build-version-webpack-plugin')
module.exports = {
  configureWebpack: config => {
    // other config
    if(process.env.NODE_ENV === 'production'){ // only use build by production
      config.plugins.push(
        new BuildVersionWebpackPlugin()
      )
    }
  }
}

webpack-cli 4

// webpack.config.js
const BuildVersionWebpackPlugin = requrie('build-version-webpack-plugin')
module.exports = {
  plugins: [
    // other plugin ...
    new BuildVersionWebpackPlugin()
  ]
}

result

create a file version.json in outputDir

{
  "commit": "",
  "branch": "",
  "commitUser": "",
  "commitEmail": ""
}