Skip to content

Commit

Permalink
Optimize performance of frontend (#645)
Browse files Browse the repository at this point in the history
* Preload font files
* Provide less font files
* Create sourcemaps

Signed-off-by: Marvin A. Ruder <[email protected]>
  • Loading branch information
marvinruder authored Oct 28, 2023
1 parent 9bbb7d0 commit 81e880c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
Binary file not shown.
Binary file not shown.
6 changes: 2 additions & 4 deletions packages/frontend/src/fonts.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
font-weight: 400;
src:
local(""),
url("/assets/fonts/inter-v12-all-ext-regular.woff2") format("woff2"),
url("/assets/fonts/inter-v12-all-ext-regular.woff") format("woff");
url("/assets/fonts/inter-v12-400.woff2") format("woff2");
font-display: swap;
}

Expand All @@ -15,7 +14,6 @@
font-weight: 700;
src:
local(""),
url("/assets/fonts/inter-v12-all-ext-700.woff2") format("woff2"),
url("/assets/fonts/inter-v12-all-ext-700.woff") format("woff");
url("/assets/fonts/inter-v12-700.woff2") format("woff2");
font-display: swap;
}
3 changes: 3 additions & 0 deletions packages/frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/>
<meta name="theme-color" content="#FFFFFF" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#202020" media="(prefers-color-scheme: dark)">
<meta name="description" content="A web service fetching and providing financial and ESG ratings for stocks.">
<link rel="preload" href="/assets/fonts/inter-v12-400.woff2" as="font" type="font/woff2">
<link rel="preload" href="/assets/fonts/inter-v12-700.woff2" as="font" type="font/woff2">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/images/<%- faviconPath %>/favicon-180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/assets/images/<%- faviconPath %>/favicon-192.png">
<link rel="icon" type="image/png" sizes="128x128" href="/assets/images/<%- faviconPath %>/favicon-128.png">
Expand Down
9 changes: 6 additions & 3 deletions packages/frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { defineConfig as defineVitestConfig } from "vitest/config";
/* eslint-disable import/no-nodejs-modules */
import fs from "fs";

import react from "@vitejs/plugin-react";
import { mergeConfig, defineConfig as defineViteConfig } from "vite";
import { createHtmlPlugin } from "vite-plugin-html";
import topLevelAwait from "vite-plugin-top-level-await";
import wasm from "vite-plugin-wasm";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
import fs from "fs";
import { defineConfig as defineVitestConfig } from "vitest/config";

const chunkList: string[] = ["@mui"];

Expand All @@ -26,6 +28,7 @@ export default mergeConfig(
manualChunks,
},
},
sourcemap: true,
},
cacheDir: ".vite",
plugins: [
Expand Down

0 comments on commit 81e880c

Please sign in to comment.