Skip to content

Commit

Permalink
🐛 fix: 将 emotion/server 的引入动态化 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Mar 29, 2023
1 parent 34a79b7 commit 9415799
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/functions/extractStaticStyle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createCache, extractStyle } from '@ant-design/cssinjs';
import CacheEntity from '@ant-design/cssinjs/es/Cache';
import createEmotionServer from '@emotion/server/create-instance';
import { version } from 'antd';

/**
Expand Down Expand Up @@ -73,6 +72,8 @@ export const extractStaticStyle = (html: string, options?: ExtractStyleOptions):
// copy from emotion ssr
// https://github.com/vercel/next.js/blob/deprecated-main/examples/with-emotion-vanilla/pages/_document.js
const styles = global.__ANTD_STYLE_CACHE_MANAGER_FOR_SSR__.getCacheList().map((cache) => {
const createEmotionServer = require('@emotion/server/create-instance').default;

const result = createEmotionServer(cache).extractCritical(html);
if (!result.css) return null;

Expand Down

0 comments on commit 9415799

Please sign in to comment.