Browse Source

chore: fix cssinjs check (#41695)

pull/41697/head
MadCcc 2 years ago
committed by GitHub
parent
commit
440b345962
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      scripts/generate-cssinjs.js

14
scripts/generate-cssinjs.js

@ -14,26 +14,26 @@ module.exports = {
const EmptyElement = React.createElement('div');
styleFiles.forEach((file) => {
const pathArr = file.split('/');
const styleIndex = pathArr.lastIndexOf('style');
const componentName = pathArr[styleIndex - 1];
let useStyle = () => {};
if (file.includes('grid')) {
// eslint-disable-next-line global-require,import/no-dynamic-require
const { useColStyle, useRowStyle } = require(file);
useStyle = () => {
useRowStyle();
useColStyle();
useStyle = (prefixCls) => {
useRowStyle(prefixCls);
useColStyle(prefixCls);
};
} else {
// eslint-disable-next-line global-require,import/no-dynamic-require
useStyle = require(file).default;
}
const Component = () => {
useStyle(key);
useStyle(`${key}-${componentName}`);
return EmptyElement;
};
const pathArr = file.split('/');
const styleIndex = pathArr.lastIndexOf('style');
const componentName = pathArr[styleIndex - 1];
beforeRender?.(componentName);
render(Component);
});

Loading…
Cancel
Save