Skip to content

Commit 65172f9

Browse files
committed
fix: resolve KaTeX CSS import error from CopilotKit
1 parent 7459d74 commit 65172f9

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dynamic from "next/dynamic";
2+
3+
const CopilotKitWrapperClient = dynamic(
4+
() => import("./CopilotKitWrapper"),
5+
{ ssr: false }
6+
);
7+
8+
export default CopilotKitWrapperClient;

next.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const webpack = require('webpack')
12
const withNextra = require('nextra')({
23
theme: 'nextra-theme-docs',
34
themeConfig: './theme.config.jsx'
@@ -8,13 +9,27 @@ const isDev = process.env.NODE_ENV !== 'production'
89
const basePath = isDev ? '' : '/docs'
910

1011
module.exports = withNextra({
12+
transpilePackages: [
13+
'@copilotkitnext/react',
14+
'@copilotkit/react-core',
15+
'streamdown',
16+
],
1117
output: 'export',
1218
images: {
1319
unoptimized: true,
1420
},
1521
basePath,
1622
assetPrefix: basePath,
1723
trailingSlash: true,
24+
webpack: (config) => {
25+
config.plugins.push(
26+
new webpack.IgnorePlugin({
27+
resourceRegExp: /katex\.min\.css$/,
28+
contextRegExp: /node_modules/,
29+
})
30+
)
31+
return config
32+
},
1833
})
1934

2035
// If you have other Next.js configurations, you can pass them as the parameter above

pages/_app.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import "../styles/custom.css";
2-
import CopilotKitWrapper from "../components/CopilotKitWrapper";
2+
import CopilotKitWrapper from "../components/CopilotKitWrapperClient";
3+
import Head from "next/head";
34

45
export default function MyApp({ Component, pageProps }) {
56
return (
6-
<CopilotKitWrapper>
7-
<Component {...pageProps} />
8-
</CopilotKitWrapper>
7+
<>
8+
<Head>
9+
<link
10+
rel="stylesheet"
11+
href="https://cdn.jsdelivr.net/npm/katex@0.16.28/dist/katex.min.css"
12+
crossOrigin="anonymous"
13+
/>
14+
</Head>
15+
<CopilotKitWrapper>
16+
<Component {...pageProps} />
17+
</CopilotKitWrapper>
18+
</>
919
);
1020
}
1121

0 commit comments

Comments
 (0)