mirror of
https://gitee.com/ShopeX/ECShopX_Store-Operations-tools-frontend
synced 2026-06-21 10:05:35 +08:00
37 lines
932 B
JavaScript
37 lines
932 B
JavaScript
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}`
|
|
}
|
|
}
|