添加当前软件版本所对应的代码提交版本、提交时间的显示
This commit is contained in:
@@ -5,6 +5,11 @@ const { merge } = require('webpack-merge')
|
||||
|
||||
const baseConfig = require('./webpack.config.base')
|
||||
|
||||
const gitInfo = {
|
||||
commit_id: '',
|
||||
commit_date: '',
|
||||
}
|
||||
|
||||
module.exports = merge(baseConfig, {
|
||||
mode: 'development',
|
||||
devtool: 'eval-source-map',
|
||||
@@ -18,6 +23,8 @@ module.exports = merge(baseConfig, {
|
||||
__VUE_OPTIONS_API__: 'true',
|
||||
__VUE_PROD_DEVTOOLS__: 'false',
|
||||
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
|
||||
COMMIT_ID: `"${gitInfo.commit_id}"`,
|
||||
COMMIT_DATE: `"${gitInfo.commit_date}"`,
|
||||
staticPath: `"${path.join(__dirname, '../../src/static').replace(/\\/g, '\\\\')}"`,
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
const webpack = require('webpack')
|
||||
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
@@ -12,6 +13,17 @@ const buildConfig = require('../webpack-build-config')
|
||||
|
||||
// let whiteListedModules = ['vue', 'vue-router', 'vuex', 'vue-i18n']
|
||||
|
||||
const gitInfo = {
|
||||
commit_id: '',
|
||||
commit_date: '',
|
||||
}
|
||||
|
||||
try {
|
||||
if (!execSync('git status --porcelain').toString().trim() || process.env.BUILD_WIN_7) {
|
||||
gitInfo.commit_id = execSync('git log -1 --pretty=format:"%H"').toString().trim()
|
||||
gitInfo.commit_date = execSync('git log -1 --pretty=format:"%ad" --date=iso-strict').toString().trim()
|
||||
}
|
||||
} catch {}
|
||||
|
||||
module.exports = merge(baseConfig, {
|
||||
mode: 'production',
|
||||
@@ -45,6 +57,8 @@ module.exports = merge(baseConfig, {
|
||||
__VUE_OPTIONS_API__: 'true',
|
||||
__VUE_PROD_DEVTOOLS__: 'false',
|
||||
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
|
||||
COMMIT_ID: `"${gitInfo.commit_id}"`,
|
||||
COMMIT_DATE: `"${gitInfo.commit_date}"`,
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
|
||||
Reference in New Issue
Block a user