|
@@ -1,3 +1,42 @@
|
|
|
|
+'use strict'
|
|
|
|
+const path = require('path')
|
|
|
|
+const ip = '192.168.1.43'
|
|
|
|
+const os = require('os')
|
|
|
|
+const fs = require("fs")
|
|
|
|
+//判断环境
|
|
|
|
+let ifaces = os.networkInterfaces()
|
|
|
|
+let localityIp = '', result = []
|
|
|
|
+for(let dev in ifaces) {
|
|
|
|
+ ifaces[dev].forEach(function(details) {
|
|
|
|
+ if(localityIp === '' && details.family === 'IPv4' && !details.internal) {
|
|
|
|
+ localityIp = details.address
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+let getFile = localityIp == ip?false:true
|
|
|
|
+/******** 获取git版本信息 ********/
|
|
|
|
+const gitHEAD = getFile ? fs.readFileSync('.git/HEAD', 'utf-8').trim() : false
|
|
|
|
+const ref = getFile ? gitHEAD.split(': ')[1] : false
|
|
|
|
+const develop = getFile ? gitHEAD.split('/')[2] : false
|
|
|
|
+const gitVersion = getFile ? fs.readFileSync('.git/' + ref, 'utf-8').trim() : false
|
|
|
|
+const buildEdition = develop && gitVersion ? develop + ': ' + gitVersion : '未配置'
|
|
|
|
+const myDate = new Date()
|
|
|
|
+const buildTime = myDate.getFullYear() +'-'+ (myDate.getMonth()+1) +'-'+ myDate.getDate() +' '+ myDate.getHours() +':'+ myDate.getMinutes();
|
|
|
|
+const logsList = getFile ? fs.readFileSync('.git/logs/HEAD', 'utf-8').replace(/\r\n|\r/g, "\n").split("\n") : false
|
|
|
|
+const buildUser = getFile ? logsList[logsList.length-2].split(" ")[2] : '未配置'
|
|
|
|
+//生成随机版本编码
|
|
|
|
+process.env.VUE_APP_RENEWAL_ENCODING = generateRandomString()
|
|
|
|
+function generateRandomString() {
|
|
|
|
+ let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
|
|
+ let randomString = "";
|
|
|
|
+ for (let i = 0; i < 24; i++) {
|
|
|
|
+ let randomIndex = Math.floor(Math.random() * chars.length);
|
|
|
|
+ randomString += chars.charAt(randomIndex);
|
|
|
|
+ }
|
|
|
|
+ return randomString;
|
|
|
|
+}
|
|
|
|
+
|
|
const { defineConfig } = require('@vue/cli-service')
|
|
const { defineConfig } = require('@vue/cli-service')
|
|
module.exports = defineConfig({
|
|
module.exports = defineConfig({
|
|
transpileDependencies: true,
|
|
transpileDependencies: true,
|
|
@@ -22,6 +61,15 @@ module.exports = defineConfig({
|
|
},
|
|
},
|
|
},
|
|
},
|
|
chainWebpack(config) {
|
|
chainWebpack(config) {
|
|
|
|
+ //标记打包时间与当前git版本信息
|
|
|
|
+ config.plugin('html').tap(args => {
|
|
|
|
+ args[0].buildUser = buildUser;
|
|
|
|
+ args[0].buildTime = buildTime;
|
|
|
|
+ args[0].buildEdition = buildEdition;
|
|
|
|
+ args[0].renewalEncoding = process.env.VUE_APP_RENEWAL_ENCODING;
|
|
|
|
+ // args[0].minify.removeComments = false
|
|
|
|
+ return args
|
|
|
|
+ })
|
|
config
|
|
config
|
|
.when(process.env.VUE_APP_ENV !== 'www.dlc.com',
|
|
.when(process.env.VUE_APP_ENV !== 'www.dlc.com',
|
|
config => {
|
|
config => {
|