Skip to content

Commit bf83c05

Browse files
committed
Performance imrovements: webpack config(uglify & chunks), code refactor
1 parent 2d9982a commit bf83c05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2726
-2273
lines changed

.babelrc.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
compact: true,
23
plugins: ["styled-jsx/babel"],
34
presets: ["@babel/preset-typescript", "@babel/react"],
4-
};
5+
}

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"@reduxjs/toolkit": "^1.9.5",
2222
"@rocicorp/rails": "^0.8.0",
2323
"@rocicorp/reflect": "^0.38.202311200859",
24-
"@web3-onboard/core": "^2.21.0",
2524
"@web3-onboard/metamask": "^2.0.1",
2625
"@web3-onboard/react": "^2.8.11",
2726
"@web3-onboard/taho": "^2.0.5",
@@ -38,22 +37,18 @@
3837
"konva": "^9.2.0",
3938
"lodash": "4.17.21",
4039
"os-browserify": "^0.3.0",
41-
"patch-package": "^8.0.0",
4240
"path-browserify": "^1.0.1",
4341
"posthog-js": "^1.88.2",
4442
"process": "^0.11.10",
45-
"raf-schd": "^4.0.3",
4643
"react": "^18.2.0",
4744
"react-dom": "^18.2.0",
4845
"react-konva": "^18.2.10",
4946
"react-markdown": "^9.0.0",
5047
"react-redux": "^8.1.2",
5148
"react-router-dom": "^5",
5249
"rehype-external-links": "^3.0.0",
53-
"stream": "^0.0.2",
5450
"stream-browserify": "^3.0.0",
5551
"stream-http": "^3.2.0",
56-
"styled-jsx": "^5.1.2",
5752
"use-image": "^1.1.1",
5853
"util": "^0.12.5",
5954
"zod": "^3.22.4"
@@ -67,7 +62,6 @@
6762
"@thesis-co/eslint-config": "^0.5.0",
6863
"@thesis/prettier-config": "github:thesis/prettier-config",
6964
"@types/dotenv-webpack": "^7.0.4",
70-
"@types/raf-schd": "^4.0.1",
7165
"@types/react": "^18.2.14",
7266
"@types/react-dom": "^18.2.6",
7367
"@types/react-router-dom": "^5",
@@ -78,9 +72,12 @@
7872
"eslint": "^8.44.0",
7973
"fork-ts-checker-webpack-plugin": "^8.0.0",
8074
"html-webpack-plugin": "^5.5.3",
75+
"patch-package": "^8.0.0",
8176
"prettier": "^2.8.1",
77+
"styled-jsx": "^5.1.2",
8278
"typescript": "^5.0.2",
8379
"webpack": "^5.88.1",
80+
"webpack-bundle-analyzer": "^4.10.1",
8481
"webpack-cli": "^5.1.4",
8582
"webpack-dev-server": "^4.15.1",
8683
"webpack-merge": "^5.7.3"

src/App.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react"
2+
import { Web3OnboardProvider } from "@web3-onboard/react"
3+
import { Provider } from "react-redux"
4+
import web3Onboard from "shared/utils/web3Onboard"
5+
import { PostHogProvider } from "posthog-js/react"
6+
import { BrowserRouter as Router } from "react-router-dom"
7+
import GlobalStyles from "ui/GlobalStyles"
8+
import { POSTHOG_API_KEY, POSTHOG_API_OPTIONS } from "config/posthog"
9+
import Dapp from "ui/DApp/Dapp"
10+
import reduxStore from "./redux-state"
11+
12+
export default function App() {
13+
return (
14+
<>
15+
<GlobalStyles />
16+
<PostHogProvider apiKey={POSTHOG_API_KEY} options={POSTHOG_API_OPTIONS}>
17+
<Provider store={reduxStore}>
18+
<Web3OnboardProvider web3Onboard={web3Onboard}>
19+
<Router>
20+
<Dapp />
21+
</Router>
22+
</Web3OnboardProvider>
23+
</Provider>
24+
</PostHogProvider>
25+
</>
26+
)
27+
}

src/config/posthog.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { PostHogConfig } from "posthog-js"
2+
3+
export const { POSTHOG_API_KEY } = process.env
4+
5+
export const POSTHOG_API_OPTIONS: Partial<PostHogConfig> = {
6+
persistence: "localStorage",
7+
autocapture: false,
8+
capture_pageview: false,
9+
disable_session_recording: true,
10+
sanitize_properties(properties) {
11+
return {
12+
...properties,
13+
// The extension has set an expectation that the lib is set to
14+
// the analytics env.
15+
$lib: process.env.ANALYTICS_ENV,
16+
}
17+
},
18+
}

src/env.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ declare module "*.mp4" {
3030
export = value
3131
}
3232

33+
declare module "webpack-bundle-analyzer"
34+
declare module "uglifyjs-webpack-plugin"
35+
3336
declare namespace NodeJS {
3437
interface ProcessEnv {
3538
NODE_ENV: "production" | "development" | "test"

src/index.tsx

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,16 @@
11
import React from "react"
22
import ReactDOM from "react-dom/client"
3-
import { Web3OnboardProvider } from "@web3-onboard/react"
4-
import { Provider } from "react-redux"
5-
import web3Onboard from "shared/utils/web3Onboard"
6-
import { PostHogProvider } from "posthog-js/react"
7-
import { BrowserRouter as Router } from "react-router-dom"
8-
import DApp from "ui/DApps"
9-
import reduxStore from "./redux-state"
10-
11-
function DAppProviders() {
12-
return (
13-
<Provider store={reduxStore}>
14-
<Web3OnboardProvider web3Onboard={web3Onboard}>
15-
<PostHogProvider
16-
apiKey={process.env.POSTHOG_API_KEY}
17-
options={{
18-
persistence: "localStorage",
19-
autocapture: false,
20-
capture_pageview: false,
21-
disable_session_recording: true,
22-
sanitize_properties(properties) {
23-
return {
24-
...properties,
25-
// The extension has set an expectation that the lib is set to
26-
// the analytics env.
27-
$lib: process.env.ANALYTICS_ENV,
28-
}
29-
},
30-
}}
31-
>
32-
<Router>
33-
<DApp />
34-
</Router>
35-
</PostHogProvider>
36-
</Web3OnboardProvider>
37-
</Provider>
38-
)
39-
}
3+
import App from "./App"
404

415
const root = document.getElementById("root")
426

437
if (root) {
448
if (process.env.SKIP_REACT_STRICT_MODE === "true") {
45-
ReactDOM.createRoot(root).render(<DAppProviders />)
9+
ReactDOM.createRoot(root).render(<App />)
4610
} else {
4711
ReactDOM.createRoot(root).render(
4812
<React.StrictMode>
49-
<DAppProviders />
13+
<App />
5014
</React.StrictMode>
5115
)
5216
}

src/public/index.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Subscape</title>
7+
<style>
8+
body {
9+
background: #142D2B;
10+
}
11+
</style>
12+
<link rel="preconnect" href="https://networkcheck.reflect-server.net" />
13+
<link rel="preconnect" href="https://rpc.tenderly.co" />
14+
<link rel="preconnect" href="https://track.customer.io" />
15+
<link rel="preconnect" href="https://featureflags.netlify.com" />
16+
</head>
17+
<body>
18+
<div id="root"></div>
719
<!-- Script for sending data to customer.io -->
820
<script type="text/javascript">
921
var _cio = _cio || [];
@@ -21,13 +33,5 @@
2133
})();
2234
</script>
2335
<!-- Script for sending data to customer.io -->
24-
<style>
25-
body {
26-
background: #142D2B;
27-
}
28-
</style>
29-
</head>
30-
<body>
31-
<div id="root"></div>
3236
</body>
3337
</html>

src/redux-state/slices/wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createSlice } from "@reduxjs/toolkit"
2-
import portrait from "shared/assets/portrait.png"
2+
import portrait from "shared/assets/portrait.webp"
33
import { ETH_ADDRESS, TAHO_ADDRESS } from "shared/constants"
44
import { TokenBalances, TransactionProgressStatus } from "shared/types"
55
import { getAllowanceTransactionID } from "shared/utils"

src/shared/assets/assistant.webp

1.33 KB
Loading
154 KB
Loading

0 commit comments

Comments
 (0)