mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
47493c0e90
* chore: collect statistic after compile * chore: code clean * chore: code clean * chore: code clean * chore: remove export in ConfigProvider * chore: only lib * test: fix lint * chore: code clean
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
/* eslint-disable import/no-unresolved,no-console */
|
|
|
|
const chalk = require('chalk');
|
|
const React = require('react');
|
|
const ReactDOMServer = require('react-dom/server');
|
|
const fs = require('fs-extra');
|
|
const antd = require('../lib');
|
|
const { statistic } = require('../lib/_util/theme/util/statistic');
|
|
const useMessageStyle = require('../lib/message/style/index').default;
|
|
const useNotificationStyle = require('../lib/notification/style/index').default;
|
|
|
|
console.log(chalk.green(`🔥 Collecting token statistics...`));
|
|
// Automatic rendering
|
|
Object.entries(antd).forEach(([key, component]) => {
|
|
if (
|
|
/[A-Z]/.test(key.charAt(0)) &&
|
|
key !== 'Form' &&
|
|
key !== 'Dropdown' &&
|
|
key !== 'Grid' &&
|
|
key !== 'ConfigProvider'
|
|
) {
|
|
ReactDOMServer.renderToString(React.createElement(component));
|
|
}
|
|
});
|
|
|
|
const EmptyElement = React.createElement('div');
|
|
|
|
// Dropdown
|
|
ReactDOMServer.renderToString(
|
|
React.createElement(antd.Dropdown, { overlay: EmptyElement }, EmptyElement),
|
|
);
|
|
|
|
// Form
|
|
ReactDOMServer.renderToString(React.createElement(antd.Form, undefined, EmptyElement));
|
|
|
|
// message
|
|
const Message = () => {
|
|
useMessageStyle('message');
|
|
return EmptyElement;
|
|
};
|
|
ReactDOMServer.renderToString(React.createElement(Message));
|
|
|
|
// Notification
|
|
const Notification = () => {
|
|
useNotificationStyle('notification');
|
|
return EmptyElement;
|
|
};
|
|
ReactDOMServer.renderToString(React.createElement(Notification));
|
|
|
|
(async () => {
|
|
const libPath = `${process.cwd()}/lib/_util/theme/util/statistic.js`;
|
|
const libContent = await fs.readFile(libPath, 'utf8');
|
|
const newLibContent = `${libContent}\nexports._statistic_build_ = ${JSON.stringify(statistic)}`;
|
|
await fs.writeFile(libPath, newLibContent, 'utf8');
|
|
console.log(chalk.green(`✅ Collecting token statistics done.`));
|
|
})();
|