mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
enhancement(web): improve font loading performance and avoid page reflow (#1087)
* enhancement: improve font loading performance and avoid page reflow chore: get rid of postcss-import (we're not using it and it's not needed for tailwind) * fix indent
This commit is contained in:
parent
64f81a4614
commit
7b77ff766e
8 changed files with 38 additions and 19 deletions
|
@ -11,6 +11,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#141415" />
|
<meta name="theme-color" content="#141415" />
|
||||||
<meta name="description" content="autobrr" />
|
<meta name="description" content="autobrr" />
|
||||||
|
<link rel="preload" href="/Inter.var.woff2" as="font" type="font/woff2" crossorigin="use-credentials">
|
||||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||||
<link rel="apple-touch-icon" href="/apple-touch-icon-iphone-60x60.png" />
|
<link rel="apple-touch-icon" href="/apple-touch-icon-iphone-60x60.png" />
|
||||||
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-ipad-76x76.png" />
|
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-ipad-76x76.png" />
|
||||||
|
@ -18,6 +19,27 @@
|
||||||
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-ipad-retina-152x152.png" />
|
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-ipad-retina-152x152.png" />
|
||||||
<title>autobrr</title>
|
<title>autobrr</title>
|
||||||
<base href="{{.BaseUrl}}">
|
<base href="{{.BaseUrl}}">
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: "Inter Var";
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 100 900;
|
||||||
|
font-display: block;
|
||||||
|
src:
|
||||||
|
local("Inter Var"), local("Inter Variable"),
|
||||||
|
local("Inter var"), local("Inter variable"),
|
||||||
|
local("InterVar"), local("InterVariable"),
|
||||||
|
local("Inter"),
|
||||||
|
url("/Inter.var.woff2") format("woff2");
|
||||||
|
}
|
||||||
|
:root {
|
||||||
|
font-family: "Inter Var", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
||||||
|
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||||
|
sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
window.APP = {};
|
window.APP = {};
|
||||||
window.APP.baseUrl = "{{.BaseUrl}}";
|
window.APP.baseUrl = "{{.BaseUrl}}";
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource-variable/inter": "^5.0.8",
|
|
||||||
"@headlessui/react": "^1.7.17",
|
"@headlessui/react": "^1.7.17",
|
||||||
"@heroicons/react": "^2.0.18",
|
"@heroicons/react": "^2.0.18",
|
||||||
"@hookform/error-message": "^2.0.1",
|
"@hookform/error-message": "^2.0.1",
|
||||||
|
@ -56,7 +55,6 @@
|
||||||
"formik": "^2.4.3",
|
"formik": "^2.4.3",
|
||||||
"http-proxy-middleware": "^2.0.6",
|
"http-proxy-middleware": "^2.0.6",
|
||||||
"postcss": "^8.4.29",
|
"postcss": "^8.4.29",
|
||||||
"postcss-import": "^15.1.0",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-debounce-input": "^3.3.0",
|
"react-debounce-input": "^3.3.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
|
10
web/pnpm-lock.yaml
generated
10
web/pnpm-lock.yaml
generated
|
@ -8,9 +8,6 @@ overrides:
|
||||||
react: ^18.2.0
|
react: ^18.2.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@fontsource-variable/inter':
|
|
||||||
specifier: ^5.0.8
|
|
||||||
version: 5.0.8
|
|
||||||
'@headlessui/react':
|
'@headlessui/react':
|
||||||
specifier: ^1.7.17
|
specifier: ^1.7.17
|
||||||
version: 1.7.17(react-dom@18.2.0)(react@18.2.0)
|
version: 1.7.17(react-dom@18.2.0)(react@18.2.0)
|
||||||
|
@ -89,9 +86,6 @@ dependencies:
|
||||||
postcss:
|
postcss:
|
||||||
specifier: ^8.4.29
|
specifier: ^8.4.29
|
||||||
version: 8.4.29
|
version: 8.4.29
|
||||||
postcss-import:
|
|
||||||
specifier: ^15.1.0
|
|
||||||
version: 15.1.0(postcss@8.4.29)
|
|
||||||
react:
|
react:
|
||||||
specifier: ^18.2.0
|
specifier: ^18.2.0
|
||||||
version: 18.2.0
|
version: 18.2.0
|
||||||
|
@ -1799,10 +1793,6 @@ packages:
|
||||||
resolution: {integrity: sha512-m0G6wlnhm/AX0H12IOWtK8gASEMffnX08RtKkCgTdHb9JpHKGloI7icFfLg9ZmQeavcvR0PKmzxClyuFPSjKWw==}
|
resolution: {integrity: sha512-m0G6wlnhm/AX0H12IOWtK8gASEMffnX08RtKkCgTdHb9JpHKGloI7icFfLg9ZmQeavcvR0PKmzxClyuFPSjKWw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@fontsource-variable/inter@5.0.8:
|
|
||||||
resolution: {integrity: sha512-WkYfFNccmEIeL2fNg0mYeLWqOoB7xD8MFxFRc4IwbSP2o8ZaBt36v5aW4by4MyrgGRMNk7uNi5LbvYKq6clPjw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@headlessui/react@1.7.17(react-dom@18.2.0)(react@18.2.0):
|
/@headlessui/react@1.7.17(react-dom@18.2.0)(react@18.2.0):
|
||||||
resolution: {integrity: sha512-4am+tzvkqDSSgiwrsEpGWqgGo9dz8qU5M3znCkC4PgkpY4HcCZzEDEvozltGGGHIKl9jbXbZPSH5TWn4sWJdow==}
|
resolution: {integrity: sha512-4am+tzvkqDSSgiwrsEpGWqgGo9dz8qU5M3znCkC4PgkpY4HcCZzEDEvozltGGGHIKl9jbXbZPSH5TWn4sWJdow==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: {
|
plugins: {
|
||||||
"postcss-import": {},
|
|
||||||
"tailwindcss/nesting": {},
|
"tailwindcss/nesting": {},
|
||||||
tailwindcss: {},
|
tailwindcss: {},
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
|
|
BIN
web/public/Inter.var.woff2
Normal file
BIN
web/public/Inter.var.woff2
Normal file
Binary file not shown.
|
@ -9,11 +9,6 @@
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: "InterVariable", "Inter Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
|
||||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
|
||||||
sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { Buffer } from "buffer";
|
import { Buffer } from "buffer";
|
||||||
|
|
||||||
import "@fontsource-variable/inter";
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import "react-tooltip/dist/react-tooltip.css";
|
import "react-tooltip/dist/react-tooltip.css";
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@ import { VitePWA } from "vite-plugin-pwa";
|
||||||
import react from "@vitejs/plugin-react-swc";
|
import react from "@vitejs/plugin-react-swc";
|
||||||
import svgr from "vite-plugin-svgr";
|
import svgr from "vite-plugin-svgr";
|
||||||
|
|
||||||
|
interface PreRenderedAsset {
|
||||||
|
name: string | undefined;
|
||||||
|
source: string | Uint8Array;
|
||||||
|
type: 'asset';
|
||||||
|
}
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default ({ mode }: ConfigEnv) => {
|
export default ({ mode }: ConfigEnv) => {
|
||||||
// early load .env file
|
// early load .env file
|
||||||
|
@ -97,6 +103,16 @@ export default ({ mode }: ConfigEnv) => {
|
||||||
build: {
|
build: {
|
||||||
manifest: true,
|
manifest: true,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
assetFileNames: (chunkInfo: PreRenderedAsset) => {
|
||||||
|
if (chunkInfo.name === "Inter.var.woff2") {
|
||||||
|
return "assets/[name][extname]";
|
||||||
|
}
|
||||||
|
return "assets/[name]-[hash][extname]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue