Skip to content

Commit

Permalink
✨ feat: extractStaticStyle 支持传入 antdCache
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Mar 19, 2023
1 parent e547a6e commit d87ddde
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/functions/extractStaticStyle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +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 @@ -36,6 +37,10 @@ interface ExtractStyleOptions {
* @default true
*/
includeAntd?: boolean;
/**
* Antd 样式缓存配置
*/
antdCache?: CacheEntity;
}
/**
* Extract Static style
Expand All @@ -46,7 +51,7 @@ export const extractStaticStyle = (html: string, options?: ExtractStyleOptions):
const shouldExtreactAntdStyle =
typeof options?.includeAntd !== 'undefined' ? options.includeAntd : true;

const styleText = extractStyle(antdCache);
const styleText = extractStyle(options?.antdCache ?? antdCache);

const antdCssString = styleText.replace(/<style\s[^>]*>/g, '').replace(/<\/style>/g, '');

Expand Down

0 comments on commit d87ddde

Please sign in to comment.