webpack 打包插件,向打包目录插入一个version.json,该json包含一些打包版本的git信息
xmf fc2b72ca72 doc: 修改版本号 | 4 years ago | |
---|---|---|
src | 4 years ago | |
.gitignore | 4 years ago | |
.npmignore | 4 years ago | |
README.md | 4 years ago | |
package.json | 4 years ago |
npm install --save-dev build-version-webpack-plugin
// 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.config.js
const BuildVersionWebpackPlugin = requrie('build-version-webpack-plugin')
module.exports = {
plugins: [
// other plugin ...
new BuildVersionWebpackPlugin()
]
}
create a file version.json in outputDir
{
"commit": "",
"branch": "",
"commitUser": "",
"commitEmail": ""
}