Skip to content

Commit

Permalink
更新版本 env文件
Browse files Browse the repository at this point in the history
  • Loading branch information
kongyijilafumi committed Apr 14, 2022
1 parent 67de115 commit 40aadb1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions .env-cmdrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
const devConfig = {
PORT: 3000, // 启动端口
HOST: "0.0.0.0", // 监听地址
NODE_ENV: "development", // 开发者模式
REACT_APP_ROUTERBASE: "/react-ant-admin", // react路由基础路径
REACT_APP_API_BASEURL: "http://127.0.0.1:8081/api/react-ant-admin", //请求地址
PUBLIC_URL: "/react-ant-admin",// 静态文件路径
}
const productionCfg = {
const proConfig = {
REACT_APP_ROUTERBASE: "/react-ant-admin", // react路由基础路径
REACT_APP_API_BASEURL: "/api/react-ant-admin", //请求地址
PUBLIC_URL: "/react-ant-admin",// 静态文件路径
NODE_ENV: "production", // 打包模式 生产模式
BUILD_PATH: "react-ant-admin", // 打包 文件夹名称
}
module.exports = Promise.resolve({

/**
* env-cmd 文档地址 https://github.com/toddbluhm/env-cmd#-help
* 命令行使用: env-cmd --verbose -e mode_name node file.js
* mode_name: 对应 mode 里面的 属性(key) 例如 development development_color
* 运行结果:
* 取出 对应 mode_name 的 值(value) Object.keys方法 把 key-value 绑定到 process.env 上
* 如 : development(mode_name): { test : "123" } => process.env.test = "123"
* 最终能够在整个项目中 使用 process.env.test
*/
const mode = {

// 本地接口正常运行 没有mock 没有 主题色
development: devConfig,
Expand All @@ -39,27 +47,30 @@ module.exports = Promise.resolve({
},

// 打包 :无主题 无mock
production: productionCfg,
production: proConfig,

// 打包 : 有主题 无mock
production_color: {
...productionCfg,
...proConfig,
COLOR: "true", // "true" 为 启动
},

// 打包 : 有主题 有mock 纯本地模式打包
production_color_mock: {
...productionCfg,
...proConfig,
COLOR: "true",
REACT_APP_MOCK: "1",
},

// GitHub pages 打包 博主使用
production_github: {
...productionCfg,
...proConfig,
COLOR: "true",
REACT_APP_API_BASEURL: "https://azhengpersonalblog.top/api/react-ant-admin",
REACT_APP_ROUTER_ISHASH: "1", // 启用哈希模式
REACT_APP_ROUTERBASE: "/"
}
})
}


module.exports = Promise.resolve(mode)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-ant-admin",
"version": "0.1.0",
"version": "1.6",
"dependencies": {
"@babel/core": "7.12.3",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
Expand Down

0 comments on commit 40aadb1

Please sign in to comment.