Skip to content

Commit f312370

Browse files
committed
migrated to snowpack from create-react-app
1 parent c03e1d7 commit f312370

File tree

5 files changed

+51
-142
lines changed

5 files changed

+51
-142
lines changed

web/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
"axios-hooks": "^1.9.0",
1111
"graphql": "^14.6.0",
1212
"graphql-tag": "^2.10.3",
13+
"http-proxy": "^1.18.1",
1314
"react": "^16.12.0",
1415
"react-dom": "^16.12.0",
15-
"react-helmet": "latest",
16-
"react-scripts": "latest",
16+
"react-helmet": "^6.1.0",
17+
"snowpack": "^3.3.3",
1718
"subscriptions-transport-ws": "^0.9.16",
1819
"urql": "^1.9.0"
1920
},
2021
"scripts": {
21-
"start": "react-scripts start",
22-
"build": "react-scripts build",
23-
"test": "react-scripts test",
24-
"eject": "react-scripts eject"
22+
"start": "snowpack dev",
23+
"build": "snowpack build",
24+
"test": "echo \"No tests to run :(\" && exit 1"
2525
},
2626
"eslintConfig": {
2727
"extends": "react-app"

web/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
To begin the development, run `npm start` or `yarn start`.
3939
To create a production bundle, use `npm run build` or `yarn build`.
4040
-->
41+
<script type="module" src="/dist/index.js"></script>
4142
</body>
4243

4344
</html>

web/snowpack.config.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/** @type {import("snowpack").SnowpackUserConfig } */
2+
3+
const httpProxy = require("http-proxy");
4+
const proxy = httpProxy.createServer({ target: "http://localhost:3000" });
5+
6+
module.exports = {
7+
env: {
8+
REACT_APP_WEBSOCKET_ENDPOINT: "ws://localhost:8080/query",
9+
},
10+
mount: {
11+
public: "/",
12+
src: "/dist",
13+
},
14+
plugins: [
15+
/* ... */
16+
],
17+
routes: [
18+
{
19+
src: "/query.*",
20+
dest: (req, res) => {
21+
proxy.web(req, res);
22+
},
23+
upgrade: (req, socket, head) => {
24+
proxy.ws(req, socket);
25+
},
26+
},
27+
/* Enable an SPA Fallback in development: */
28+
{ match: "routes", src: ".*", dest: "/index.html" },
29+
],
30+
optimize: {
31+
/* Example: Bundle your final build: */
32+
// "bundle": true,
33+
},
34+
packageOptions: {
35+
/* ... */
36+
},
37+
devOptions: {
38+
/* ... */
39+
},
40+
buildOptions: {
41+
/* ... */
42+
},
43+
};

web/src/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Provider as UrqlProvider, createClient, defaultExchanges, subscriptionE
55
import { SubscriptionClient } from 'subscriptions-transport-ws';
66

77
const subscriptionClient = new SubscriptionClient(
8-
process.env.REACT_APP_WEBSOCKET_ENDPOINT,
8+
import.meta.env.REACT_APP_WEBSOCKET_ENDPOINT,
99
{}
1010
);
1111
const gqlclient = createClient({

web/src/serviceWorker.js

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)