From 37cd19c567e910a73558709ea84d2a52a054c525 Mon Sep 17 00:00:00 2001
From: Gabe Kangas
Date: Tue, 10 Jan 2023 00:33:54 -0800
Subject: [PATCH] Inline some CSS upfront for performance. #2167
---
web/pages/_document.tsx | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/web/pages/_document.tsx b/web/pages/_document.tsx
index e1e9cbbb7..80069e99d 100644
--- a/web/pages/_document.tsx
+++ b/web/pages/_document.tsx
@@ -1,9 +1,32 @@
+/* eslint-disable react/no-danger */
import { Html, Head, Main, NextScript } from 'next/document';
+import { readFileSync } from 'fs';
+import { join } from 'path';
+
+class InlineStylesHead extends Head {
+ getCssLinks: Head['getCssLinks'] = ({ allFiles }) => {
+ const { assetPrefix } = this.context;
+ if (!allFiles || allFiles.length === 0) return null;
+ return allFiles
+ .filter((file: any) => /\.css$/.test(file))
+ .map((file: any) => (
+
+ ));
+ };
+}
+
export default function Document() {
return (
-
+