Skip to content

Commit 57f6a89

Browse files
chore: use dev and prod .env files
1 parent 9e4332c commit 57f6a89

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ dist
1212
dist-ssr
1313
*.local
1414

15+
# Env files
16+
.env
17+
.env.*
18+
1519
# Editor directories and files
1620
.vscode/*
1721
!.vscode/extensions.json

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
# Running locally
1212

13-
- Run `cp .env.example .env.local`
13+
- Run `cp .env.example .env.development`
1414
- Run `npm run dev`
1515

1616
## Build
1717

18+
- Run `cp .env.example .env.production`
1819
- Run `npm ci`
1920
- Run `npm run build`
2021
- Serve static assets in `./dist` with preferred tool. Ex. `npx run serve`

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
9+
"build:dev": "tsc && vite build --mode development",
910
"test": "vitest",
1011
"lint": "prettier --check . && eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1112
"lint:fix": "prettier --write .",

src/api/ws/ConnectionProvider.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import {
1212
messageEventType,
1313
} from "./ConnectionContext";
1414

15-
const VITE_WEBSOCKET_URL = (
16-
import.meta.env.VITE_WEBSOCKET_URL as string
17-
)?.trim();
15+
const VITE_WEBSOCKET_URL = import.meta.env.PROD
16+
? null
17+
: (import.meta.env.VITE_WEBSOCKET_URL as string)?.trim();
1818

1919
export function ConnectionProvider({ children }: PropsWithChildren) {
2020
const [ctxValue, _setCtxValue] = useState(defaultCtxValue);
21+
2122
// connect to current host via websocket
2223
const websocketUrl = VITE_WEBSOCKET_URL
2324
? VITE_WEBSOCKET_URL

0 commit comments

Comments
 (0)