Commit 5838f8b3 authored by 前端-许佳敏's avatar 前端-许佳敏

chore: 优化构建流程

parent e5c8a1ed
......@@ -2,6 +2,7 @@ const gulp = require('gulp')
const envValue = require('../env')
const path = require('path')
const fs = require('fs')
const { setEnv, getEnv } = require('./utils/envTool')
const isProduction = process.env.NODE_ENV === 'production'
......@@ -36,13 +37,11 @@ function genarateConfig() {
// 构建时带上的环境变量
const PRO_ENV = process.env.PRO_ENV
if (PRO_ENV) {
process.env.SITE_ID = envValue[PRO_ENV].SITE_ID
process.env.BACK_GATEWAY = envValue[PRO_ENV].BACK_GATEWAY
process.env.USE_ROUTE_CONFIG = envValue[PRO_ENV].USE_ROUTE_CONFIG
process.env.SOCKET_URL = envValue[PRO_ENV].SOCKET_URL
process.env.ssh = envValue[PRO_ENV].ssh
if (!PRO_ENV) {
throw `请传入PRO_ENV`
}
setEnv(getEnv(envValue))
function runTask(toRun) {
const metadata = { task: toRun };
......
function getEnv(envConfig) {
if (!envConfig) {
throw `检查是否传入PRO_ENV`
}
return envConfig[process.env.PRO_ENV]
}
function setEnv(envs) {
Object.keys(envs).forEach(key => {
process.env[key] = envs[key]
})
}
module.exports = {
getEnv,
setEnv,
}
const YAPI_URL = require('./env.js')[process.env.PRO_ENV]
process.env.YAPI_URL = require('./env')[process.env.PRO_ENV].YAPI_URL
if (!YAPI_URL) {
if (!process.env.YAPI_URL) {
throw 'yapi链接不存在'
}
const tokenList = [
{ name: 'LogisticsV2', token: '732fb8e33970ff5dee830423a630e8e85c3ef3293abba7581b16749dfce8608b', categoryIds: [0], }, // 物流服务
{ name: 'ProductV2', token: 'df37f2a0e3829c4288708ae211920bdbdee55e5e2f48b1e8cf7d1925ac618d9a', categoryIds: [0], }, // 商品服务V2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment