I followed the antd and nextjs doc to config the project.
Added this code into the ./scripts/genAntdCss.tsx
file:
import { extractStyle } from '@ant-design/static-style-extract';
import fs from 'fs';
const outputPath = './public/antd.min.css';
const css = extractStyle();
fs.writeFileSync(outputPath, css);
and this is App.tsx file:
import { StyleProvider } from '@ant-design/cssinjs';
import type { AppProps } from 'next/app';
import '../public/antd.min.css';
export default function App({ Component, pageProps }: AppProps) {
return (
<StyleProvider hashPriority='high'>
<Component {...pageProps} />
</StyleProvider>
);
}
these commands added to package.json
file:
"predev": "ts-node --project ./tsconfig.node.json ./scripts/genAntdCss.tsx",
"prebuild": "ts-node --project ./tsconfig.node.json ./scripts/genAntdCss.tsx"
Do you have any idea to fix this?