Skip to content

Commit 5ebf311

Browse files
authored
🔖 ⬆️ 🔨 Migrate to antd-pro@2.1
🔖 ⬆️ 🔨 Migrate to antd-pro@2.1
2 parents 8de2ddd + 8ba3728 commit 5ebf311

File tree

336 files changed

+16663
-4443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+16663
-4443
lines changed

.temp/ant-design-pro.less

Lines changed: 3449 additions & 0 deletions
Large diffs are not rendered by default.

.umirc.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

config/config.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// https://umijs.org/config/
2+
import os from 'os';
3+
import pageRoutes from './router.config';
4+
import webpackPlugin from './plugin.config';
5+
import defaultSettings from '../src/defaultSettings';
6+
7+
const plugins = [
8+
[
9+
'umi-plugin-react',
10+
{
11+
antd: true,
12+
dva: {
13+
hmr: true,
14+
},
15+
targets: {
16+
ie: 11,
17+
},
18+
locale: {
19+
enable: true, // default false
20+
default: 'zh-CN', // default zh-CN
21+
baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
22+
},
23+
routes: {
24+
update(routes) {
25+
return [...require("../src/pages/_routes"), ...routes];
26+
}
27+
},
28+
dynamicImport: {
29+
loadingComponent: './components/PageLoading/index',
30+
},
31+
pwa: {
32+
workboxPluginMode: 'InjectManifest',
33+
workboxOptions: {
34+
importWorkboxFrom: 'local',
35+
},
36+
},
37+
...(!process.env.TEST && os.platform() === 'darwin'
38+
? {
39+
dll: {
40+
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
41+
exclude: ['@babel/runtime'],
42+
},
43+
hardSource: true,
44+
}
45+
: {}),
46+
},
47+
],
48+
[
49+
"umi-plugin-authorize",
50+
{
51+
authorize: [
52+
{
53+
guard: ["./src/pages/Authorized"],
54+
include: /\//,
55+
exclude: /\/User/
56+
}
57+
]
58+
}
59+
]
60+
];
61+
62+
// 针对 preview.pro.ant.design 的 GA 统计代码
63+
// 业务上不需要这个
64+
if (process.env.APP_TYPE === 'site') {
65+
plugins.push([
66+
'umi-plugin-ga',
67+
{
68+
code: 'UA-72788897-6',
69+
},
70+
]);
71+
}
72+
73+
export default {
74+
// add for transfer to umi
75+
plugins,
76+
targets: {
77+
ie: 11,
78+
},
79+
define: {
80+
APP_TYPE: process.env.APP_TYPE || '',
81+
},
82+
// 路由配置
83+
// routes: pageRoutes,
84+
// Theme for antd
85+
// https://ant.design/docs/react/customize-theme-cn
86+
theme: {
87+
'primary-color': defaultSettings.primaryColor,
88+
},
89+
externals: {
90+
'@antv/data-set': 'DataSet',
91+
},
92+
// proxy: {
93+
// '/server/api/': {
94+
// target: 'https://preview.pro.ant.design/',
95+
// changeOrigin: true,
96+
// pathRewrite: { '^/server': '' },
97+
// },
98+
// },
99+
ignoreMomentLocale: true,
100+
lessLoaderOptions: {
101+
javascriptEnabled: true,
102+
},
103+
disableRedirectHoist: true,
104+
cssLoaderOptions: {
105+
modules: true,
106+
getLocalIdent: (context, localIdentName, localName) => {
107+
if (
108+
context.resourcePath.includes('node_modules') ||
109+
context.resourcePath.includes('ant.design.pro.less') ||
110+
context.resourcePath.includes('global.less')
111+
) {
112+
return localName;
113+
}
114+
const match = context.resourcePath.match(/src(.*)/);
115+
if (match && match[1]) {
116+
const antdProPath = match[1].replace('.less', '');
117+
const arr = antdProPath
118+
.split('/')
119+
.map(a => a.replace(/([A-Z])/g, '-$1'))
120+
.map(a => a.toLowerCase());
121+
return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
122+
}
123+
return localName;
124+
},
125+
},
126+
manifest: {
127+
basePath: '/',
128+
},
129+
130+
chainWebpack: webpackPlugin,
131+
};

config/plugin.config.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Change theme plugin
2+
3+
import MergeLessPlugin from 'antd-pro-merge-less';
4+
import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
5+
import path from 'path';
6+
7+
export default config => {
8+
// pro 和 开发环境再添加这个插件
9+
if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
10+
// 将所有 less 合并为一个供 themePlugin使用
11+
const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
12+
const stylesDir = path.join(__dirname, '../src/');
13+
14+
config.plugin('merge-less').use(MergeLessPlugin, [
15+
{
16+
stylesDir,
17+
outFile,
18+
},
19+
]);
20+
21+
config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
22+
{
23+
antDir: path.join(__dirname, '../node_modules/antd'),
24+
stylesDir,
25+
varFile: path.join(__dirname, '../node_modules/antd/lib/style/themes/default.less'),
26+
mainLessFile: outFile, // themeVariables: ['@primary-color'],
27+
indexFileName: 'index.html',
28+
generateOne: true,
29+
lessUrl: 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js',
30+
},
31+
]);
32+
}
33+
};

0 commit comments

Comments
 (0)