Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Inline some CSS upfront for performance. #2167

Gabe Kangas150f0976645c
diff --git a/web/pages/_document.tsx b/web/pages/_document.tsx
index e1e9cbbb75..80069e99d3 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) => (
+ <style
+ key={file}
+ nonce={this.props.nonce}
+ data-href={`${assetPrefix}/_next/${file}`}
+ dangerouslySetInnerHTML={{
+ __html: readFileSync(join(process.cwd(), '.next', file), 'utf-8'),
+ }}
+ />
+ ));
+ };
+}
+
export default function Document() {
return (
<Html lang="en">
- <Head />
+ <InlineStylesHead />
<body>
<Main />
<NextScript />