mirror of
https://gitee.com/ShopeX/ECShopX_Store-Operations-tools-frontend
synced 2026-08-11 06:45:33 +08:00
chore(release): 4.0.0
This commit is contained in:
36
config/utils.js
Normal file
36
config/utils.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const crypto = require('crypto')
|
||||
const chalk = require('chalk')
|
||||
const pkg = require('../package.json')
|
||||
|
||||
function digest(str) {
|
||||
return crypto.createHash('md5').update(str).digest('hex')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getEnvs() {
|
||||
const envs = Object.keys(process.env).reduce((ret, key) => {
|
||||
const val = process.env[key]
|
||||
if (key.indexOf('APP_') >= 0) {
|
||||
// console.log(chalk.green(`${key}=${val}`));
|
||||
ret[key] = val
|
||||
}
|
||||
return ret
|
||||
}, {})
|
||||
return envs
|
||||
},
|
||||
|
||||
getDefineConstants(consts) {
|
||||
consts = Object.keys(consts).reduce((val, k) => {
|
||||
val[`process.env.${k}`] = process.env.TARO_ENV == 'h5' ? `'${consts[k]}'` : consts[k]
|
||||
return val
|
||||
}, {})
|
||||
return consts
|
||||
},
|
||||
|
||||
getCacheIdentifier(consts = {}) {
|
||||
const env = process.env.NODE_ENV || 'development'
|
||||
const envHash = digest(JSON.stringify(consts))
|
||||
|
||||
return `cache-loader:${pkg.version} ${env} ${envHash}`
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user