Skip to content

Commit

Permalink
Use parcel proxy instead of NODE_ENV for local development with HMR
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrews committed Apr 17, 2023
1 parent 5376bcf commit c43c6dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 6 additions & 0 deletions web/.proxyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"/ws": {
"target": "http://localhost:8108/",
"ws": true
}
}
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"shx": "^0.3.4"
},
"scripts": {
"start": "parcel public/index.html",
"start": "parcel --port 1234 --hmr-port 1201 public/index.html --open",
"build": "yarn patch-patternfly; parcel build public/index.html",
"clean": "rimraf .cache .tmp lib build",
"clean": "rimraf dist",
"//": "TODO: patch-patternfly is to fix an upstream problem tracked at: https://github.com/patternfly/patternfly/issues/4930",
"patch-patternfly": "shx sed -i 's/..\\/..\\/assets\\//\\/node_modules\\/@patternfly\\/react-styles\\/css\\/assets\\//g' node_modules/@patternfly/react-styles/css/components/BackgroundImage/background-image.css node_modules/@patternfly/react-styles/css/components/AboutModalBox/about-modal-box.css node_modules/@patternfly/react-styles/css/components/FormControl/form-control.css"
}
Expand Down
11 changes: 2 additions & 9 deletions web/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ import ReconnectingWebSocket from "reconnecting-websocket";
import MainLayout from "./MainLayout";
import { useEffect, useState } from "react";

// configure the wsurl and url dynamically based on prod or dev settings
const wsurl =
process.env.NODE_ENV === "production"
? "ws://" + window.location.host + "/ws"
: "ws://localhost:8884/ws";
const url =
process.env.NODE_ENV === "production"
? window.location.protocol + "//" + window.location.host
: "http://localhost:8884";
const wsurl = "ws://" + window.location.host + "/ws";
const url = window.location.protocol + "//" + window.location.host;

const rws = new ReconnectingWebSocket(wsurl);

Expand Down

0 comments on commit c43c6dc

Please sign in to comment.