Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"sass": "1.70.0",
"subset-font": "2.3.0",
"typescript": "5.5.4",
"unplugin-inject-preload": "3.0.0",
"vite": "6.0.11",
"vite-bundle-visualizer": "1.0.1",
"vite-plugin-checker": "0.7.2",
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/html/head.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<head>
<link
rel="preload"
href="/webfonts/RobotoMono-Regular.woff2"
type="font/woff2"
as="font"
crossorigin
/>
<link
rel="preload"
href="/webfonts/LexendDeca-Regular.woff2"
type="font/woff2"
as="font"
crossorigin
/>

<script>
document.addEventListener("keydown", function (e) {
if (e.key == "Escape") e.preventDefault();
Expand Down Expand Up @@ -89,7 +104,6 @@
<meta name="twitter:card" content="summary_large_image" />
<meta name="darkreader-lock" />
<meta http-equiv="Cache-Control" content="no-store" />
<link rel="preload" href="styles/vendor.scss" as="style" />
<link rel="stylesheet" href="styles/vendor.scss" />
<link rel="stylesheet" href="styles/index.scss" />
</head>
26 changes: 26 additions & 0 deletions frontend/vite.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { splitVendorChunkPlugin } from "vite";
import childProcess from "child_process";
import { checker } from "vite-plugin-checker";
import { writeFileSync } from "fs";
// eslint-disable-next-line import/no-unresolved
import UnpluginInjectPreload from "unplugin-inject-preload/vite";

function pad(numbers, maxLength, fillString) {
return numbers.map((number) =>
Expand Down Expand Up @@ -84,6 +86,7 @@ export default {
splitVendorChunkPlugin(),
VitePWA({
// injectRegister: "networkfirst",
injectRegister: "script-defer",
registerType: "autoUpdate",
manifest: {
short_name: "Monkeytype",
Expand Down Expand Up @@ -143,6 +146,29 @@ export default {
},
},
]),
UnpluginInjectPreload({
files: [
{
outputMatch: /css\/vendor.*\.css$/,
attributes: {
as: "style",
type: "text/css",
rel: "preload",
crossorigin: true,
},
},
{
outputMatch: /.*\.woff2$/,
attributes: {
as: "font",
type: "font/woff2",
rel: "preload",
crossorigin: true,
},
},
],
injectTo: "head-prepend",
}),
],
build: {
emptyOutDir: true,
Expand Down
46 changes: 46 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.