🐎 ci(版本号):
构建版本号/分支信息
This commit is contained in:
@@ -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 // 不改变函数名称
|
||||
|
||||
@@ -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
@@ -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插件对打包体积进行分析。
|
||||
|
||||
Reference in New Issue
Block a user