Skip to content

Commit

Permalink
feat: Custom dev ui port(load env from .env)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankFang committed Jun 6, 2023
1 parent fd9166b commit c189a86
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 9 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"bootstrap": "npx cross-env lerna bootstrap && lerna link",
"start:ui": "cd packages/neuron-ui && yarn run start",
"start:wallet": "cd packages/neuron-wallet && yarn run start:debug",
"start": "concurrently \"cross-env BROWSER=none yarn run start:ui\" \"wait-on http://127.0.0.1:3000 && yarn run start:wallet\"",
"start": "zx scripts/start.mjs",
"clean": "lerna run --stream clean",
"prebuild": "yarn clean",
"build": "lerna run --stream build",
Expand Down Expand Up @@ -56,7 +56,8 @@
"prettier": "2.8.7",
"ts-jest": "27.1.5",
"typescript": "5.0.4",
"wait-on": "6.0.1"
"wait-on": "6.0.1",
"zx": "^7.2.2"
},
"dependencies": {},
"resolutions": {
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-wallet/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ const fileBase = (() => {
return 'dev/'
})()

const port = process.env.PORT || 3000
const env = {
app,
isDevMode,
isTestMode,
fileBasePath: path.resolve(app.getPath('userData'), fileBase),
mainURL: isDevMode ? 'http://localhost:3000' : `file://${path.join(__dirname, '../dist/neuron-ui/index.html')}`,
mainURL: isDevMode ? `http://localhost:${port}` : `file://${path.join(__dirname, '../dist/neuron-ui/index.html')}`,
}

export default env
8 changes: 8 additions & 0 deletions scripts/start.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import dotenv from 'dotenv'
import path from 'path'
dotenv.config({ path: path.join(__dirname, '..', 'packages', 'neuron-wallet', '.env.development.local')})
await Promise.all([
$`cross-env BROWSER=none PORT=${process.env.PORT} yarn run start:ui`,
$`wait-on http://127.0.0.1:${process.env.PORT} && yarn run start:wallet`
])
console.log('bye')
Loading

0 comments on commit c189a86

Please sign in to comment.