Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] docs: bump umi to canary #48307

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 21 additions & 41 deletions .dumi/theme/plugin.ts
Expand Up @@ -182,26 +182,6 @@ const RoutesPlugin = (api: IApi) => {
// exclude dynamic route path, to avoid deploy failed by `:id` directory
.filter((f) => !f.path.includes(':'))
.map((file) => {
let globalStyles = '';

// Debug for file content: uncomment this if need check raw out
// const tmpFileName = `_${file.path.replace(/\//g, '-')}`;
// const tmpFilePath = path.join(api.paths.absOutputPath, tmpFileName);
// fs.writeFileSync(tmpFilePath, file.content, 'utf8');

// extract all emotion style tags from body
file.content = file.content.replace(
/<style (data-emotion|data-sandpack)[\S\s]+?<\/style>/g,
(s) => {
globalStyles += s;

return '';
},
);

// insert emotion style tags to head
file.content = file.content.replace('</head>', `${globalStyles}</head>`);

// 1. 提取 antd-style 样式
const styles = extractEmotionStyle(file.content);

Expand All @@ -219,27 +199,27 @@ const RoutesPlugin = (api: IApi) => {
});

// Insert antd style to head
const matchRegex = /<style data-type="antd-cssinjs">([\S\s]+?)<\/style>/;
const matchList = file.content.match(matchRegex) || [];

let antdStyle = '';

matchList.forEach((text) => {
file.content = file.content.replace(text, '');
antdStyle += text.replace(matchRegex, '$1');
});

const cssFile = writeCSSFile('antd', antdStyle, antdStyle);
file.content = addLinkStyle(file.content, cssFile, true);

// Insert antd cssVar to head
const cssVarMatchRegex = /<style data-type="antd-css-var"[\S\s]+?<\/style>/;
const cssVarMatchList = file.content.match(cssVarMatchRegex) || [];

cssVarMatchList.forEach((text) => {
file.content = file.content.replace(text, '');
file.content = file.content.replace('<head>', `<head>${text}`);
});
// const matchRegex = /<style data-type="antd-cssinjs">([\S\s]+?)<\/style>/;
// const matchList = file.content.match(matchRegex) || [];
//
// let antdStyle = '';
//
// matchList.forEach((text) => {
// file.content = file.content.replace(text, '');
// antdStyle += text.replace(matchRegex, '$1');
// });
//
// const cssFile = writeCSSFile('antd', antdStyle, antdStyle);
// file.content = addLinkStyle(file.content, cssFile, true);
//
// // Insert antd cssVar to head
// const cssVarMatchRegex = /<style data-type="antd-css-var"[\S\s]+?<\/style>/;
// const cssVarMatchList = file.content.match(cssVarMatchRegex) || [];
//
// cssVarMatchList.forEach((text) => {
// file.content = file.content.replace(text, '');
// file.content = file.content.replace('<head>', `<head>${text}`);
// });

return file;
}),
Expand Down
6 changes: 6 additions & 0 deletions package.json
Expand Up @@ -357,6 +357,12 @@
"overrides": {
"dumi-plugin-color-chunk": {
"dumi": "^2.3.0-beta.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个需要改吗?

},
"dumi": {
"umi": "canary",
"@umijs/bundler-utils": "canary",
"@umijs/core": "canary",
"@umijs/utils": "canary"
}
},
"size-limit": [
Expand Down