🐎 ci(版本号):

构建版本号/分支信息
This commit is contained in:
mrcuix
2022-07-25 19:16:12 +08:00
parent 1dfce28a75
commit a59d608f09
4 changed files with 45 additions and 2 deletions
+3
View File
@@ -17,6 +17,9 @@ module.exports = {
args: [{
terserOptions: {
compress: true, // 默认使用terser压缩
// compress: {
// drop_console: true, // 去掉打印
// }, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true // 不改变函数名称
+9
View File
@@ -1,3 +1,10 @@
const path = require('path')
const childProcess = require('child_process');
const versions = childProcess.execSync('git rev-parse --abbrev-ref HEAD', { 'encoding': 'utf8' }) != "HEAD\n" ? childProcess.execSync('git rev-parse --abbrev-ref HEAD', { 'encoding': 'utf8' }) : childProcess.execSync('git describe --tags --abbrev=0', { 'encoding': 'utf8' })
const CURRENT_GITHASH = childProcess.execSync('git rev-parse --short HEAD', { 'encoding': 'utf8' })
const CURRENT_VERSION = `Version: ${JSON.stringify(process.env.CODE_BRANCH || versions)} ${CURRENT_GITHASH} ${new Date().toLocaleString()}`.replace(/\"|\\n/g, '');
const config = {
projectName: 'EShop',
date: '2022-4-6',
@@ -11,6 +18,8 @@ const config = {
outputRoot: 'dist',
plugins: [],
defineConstants: {
CURRENT_VERSION: JSON.stringify(CURRENT_VERSION),
CURRENT_GITHASH: JSON.stringify(CURRENT_GITHASH),
CURRENT_ENV: JSON.stringify(process.env.NODE_ENV)
},
copy: {
+26 -1
View File
@@ -5,7 +5,32 @@ module.exports = {
},
defineConstants: {
},
mini: {},
mini: {
optimizeMainPackage: {
enable: true
},
webpackChain: (chain, webpack) => {
chain.merge({
plugin: {
install: {
plugin: require('terser-webpack-plugin'),
args: [{
terserOptions: {
// compress: true, // 默认使用terser压缩
compress: {
drop_console: true, // 去掉打印
}, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true // 不改变函数名称
}
}]
}
}
})
}
},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。