Skip to content

Commit

Permalink
前端-增加env文件,用于工程化判断 link #38
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonczc committed Nov 17, 2021
1 parent f2f79c7 commit b7afc97
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENV=development
REACT_APP_API_URL=
2 changes: 2 additions & 0 deletions frontend/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENV=test
REACT_APP_API_URL=
2 changes: 2 additions & 0 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_ENV=production
REACT_APP_API_URL=
5 changes: 5 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@types/react-router-dom": "^5.1.8",
"antd": "^4.16.9",
"axios": "^0.21.1",
"dotenv-cli": "^4.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^5.2.0",
Expand All @@ -31,7 +32,11 @@
},
"scripts": {
"start": "react-scripts start",
"start:dev": "dotenv -e .env.dev react-scripts start",
"start:production": "dotenv -e .env.production react-scripts start",
"build": "react-scripts build",
"build:dev": "dotenv -e .env.dev react-scripts build",
"build:production": "dotenv -e .env.production react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import CreatePluginPage from "./scenes/app/pages/developer/CreatePluginPage";
import PluginListPage from "./scenes/app/pages/PluginListPage";
import AdminPluginListPage from "./scenes/app/pages/administrator/AdminPluginListPage";
const RouterConfig = ()=> {
const mode = process.env.REACT_APP_API_URL
console.log(mode)
return (
<div>
<HashRouter>
Expand Down
21 changes: 18 additions & 3 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4028,7 +4028,7 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
safe-buffer "^5.0.1"
sha.js "^2.4.8"

[email protected], cross-spawn@^7.0.0, cross-spawn@^7.0.2:
[email protected], cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
Expand Down Expand Up @@ -4659,7 +4659,17 @@ dot-prop@^5.2.0:
dependencies:
is-obj "^2.0.0"

[email protected]:
dotenv-cli@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/dotenv-cli/-/dotenv-cli-4.1.0.tgz#424d876833796f0bbd0eb6aab63647fe252aff37"
integrity sha512-HMXB6LRFJp5fhNurla9E1zrGIlx788/DtaHJfSOXxyAqFq77zrI2y0ow5i6AhviE4IBeW3uVgKAfwOgrGDyzSQ==
dependencies:
cross-spawn "^7.0.1"
dotenv "^8.1.0"
dotenv-expand "^5.1.0"
minimist "^1.1.3"

[email protected], dotenv-expand@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-5.1.0.tgz#3fbaf020bfd794884072ea26b1e9791d45a629f0"
integrity sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==
Expand All @@ -4669,6 +4679,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==

dotenv@^8.1.0:
version "8.6.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b"
integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==

duplexer@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
Expand Down Expand Up @@ -7823,7 +7838,7 @@ [email protected], minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"

minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
Expand Down

0 comments on commit b7afc97

Please sign in to comment.