|
@@ -1,6 +1,17 @@
|
|
|
'use strict'
|
|
|
const path = require('path')
|
|
|
|
|
|
+// 获取git版本信息
|
|
|
+const fs = require("fs")
|
|
|
+const gitHEAD = fs.readFileSync('.git/HEAD', 'utf-8').trim()
|
|
|
+const ref = gitHEAD.split(': ')[1]
|
|
|
+const develop = gitHEAD.split('/')[2]
|
|
|
+const gitVersion = fs.readFileSync('.git/' + ref, 'utf-8').trim()
|
|
|
+const buildEdition = develop + ': ' + gitVersion
|
|
|
+const myDate = new Date();
|
|
|
+const buildTime = myDate.getFullYear() +'-'+ (myDate.getMonth()+1) +'-'+ myDate.getDate() +' '+ myDate.getHours() +':'+ myDate.getMinutes();
|
|
|
+const buildUser = fs.readFileSync('.git/logs/HEAD', 'utf-8').match(/<(\S*)>/)[1].match(/\+(\S*)@/)[1]
|
|
|
+
|
|
|
function resolve(dir) {
|
|
|
return path.join(__dirname, dir)
|
|
|
}
|
|
@@ -98,6 +109,14 @@ module.exports = {
|
|
|
config
|
|
|
.when(process.env.NODE_ENV !== 'development',
|
|
|
config => {
|
|
|
+ //标记打包时间与当前git版本信息
|
|
|
+ config.plugin('html').tap(args => {
|
|
|
+ args[0].buildUser = buildUser;
|
|
|
+ args[0].buildTime = buildTime;
|
|
|
+ args[0].buildEdition = buildEdition;
|
|
|
+ args[0].minify.removeComments = false;
|
|
|
+ return args
|
|
|
+ })
|
|
|
config
|
|
|
.plugin('ScriptExtHtmlWebpackPlugin')
|
|
|
.after('html')
|