|
@@ -1,89 +1,143 @@
|
|
|
-// ref: https://umijs.org/config/
|
|
|
|
|
-import { primaryColor } from '../src/defaultSettings';
|
|
|
|
|
|
|
+// https://umijs.org/config/
|
|
|
|
|
+import os from 'os';
|
|
|
|
|
+import webpackPlugin from './plugin.config';
|
|
|
|
|
+import defaultSettings from '../src/defaultSettings';
|
|
|
|
|
+import slash from 'slash2';
|
|
|
|
|
|
|
|
-export default {
|
|
|
|
|
- plugins: [
|
|
|
|
|
- [
|
|
|
|
|
- 'umi-plugin-react',
|
|
|
|
|
- {
|
|
|
|
|
- antd: true,
|
|
|
|
|
- dva: {
|
|
|
|
|
- hmr: true,
|
|
|
|
|
- },
|
|
|
|
|
- targets: {
|
|
|
|
|
- ie: 11,
|
|
|
|
|
- },
|
|
|
|
|
- locale: {
|
|
|
|
|
- enable: true, // default false
|
|
|
|
|
- default: 'zh-CN', // default zh-CN
|
|
|
|
|
- baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
|
|
|
|
|
- },
|
|
|
|
|
- dynamicImport: {
|
|
|
|
|
- loadingComponent: './components/PageLoading/index',
|
|
|
|
|
- },
|
|
|
|
|
|
|
+const plugins = [
|
|
|
|
|
+ [
|
|
|
|
|
+ 'umi-plugin-react',
|
|
|
|
|
+ {
|
|
|
|
|
+ antd: true,
|
|
|
|
|
+ dva: {
|
|
|
|
|
+ hmr: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ locale: {
|
|
|
|
|
+ enable: true, // default false
|
|
|
|
|
+ default: 'zh-CN', // default zh-CN
|
|
|
|
|
+ baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
|
|
|
},
|
|
},
|
|
|
- ],
|
|
|
|
|
- [
|
|
|
|
|
- 'umi-plugin-pro-block',
|
|
|
|
|
- {
|
|
|
|
|
- moveMock: false,
|
|
|
|
|
- moveService: false,
|
|
|
|
|
- modifyRequest: true,
|
|
|
|
|
- autoAddMenu: true,
|
|
|
|
|
|
|
+ dynamicImport: {
|
|
|
|
|
+ loadingComponent: './components/PageLoading/index',
|
|
|
|
|
+ webpackChunkName: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ pwa: {
|
|
|
|
|
+ workboxPluginMode: 'InjectManifest',
|
|
|
|
|
+ workboxOptions: {
|
|
|
|
|
+ importWorkboxFrom: 'local',
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
- ],
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ 'umi-plugin-pro-block',
|
|
|
|
|
+ {
|
|
|
|
|
+ moveMock: false,
|
|
|
|
|
+ moveService: false,
|
|
|
|
|
+ modifyRequest: true,
|
|
|
|
|
+ autoAddMenu: true,
|
|
|
|
|
+ },
|
|
|
],
|
|
],
|
|
|
|
|
+ // ...(!process.env.TEST && os.platform() === 'darwin'
|
|
|
|
|
+ // ? {
|
|
|
|
|
+ // dll: {
|
|
|
|
|
+ // include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
|
|
|
|
|
+ // exclude: ['@babel/runtime'],
|
|
|
|
|
+ // },
|
|
|
|
|
+ // hardSource: true,
|
|
|
|
|
+ // }
|
|
|
|
|
+ // : {}),
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+// 针对 preview.pro.ant.design 的 GA 统计代码
|
|
|
|
|
+// 业务上不需要这个
|
|
|
|
|
+if (process.env.APP_TYPE === 'site') {
|
|
|
|
|
+ plugins.push([
|
|
|
|
|
+ 'umi-plugin-ga',
|
|
|
|
|
+ {
|
|
|
|
|
+ code: 'UA-72788897-6',
|
|
|
|
|
+ },
|
|
|
|
|
+ ]);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ // add for transfer to umi
|
|
|
|
|
+ plugins,
|
|
|
|
|
+ define: {
|
|
|
|
|
+ APP_TYPE: process.env.APP_TYPE || '',
|
|
|
|
|
+ },
|
|
|
|
|
+ treeShaking: true,
|
|
|
targets: {
|
|
targets: {
|
|
|
ie: 11,
|
|
ie: 11,
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 路由相关配置
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ // 路由配置
|
|
|
routes: [
|
|
routes: [
|
|
|
{
|
|
{
|
|
|
path: '/user',
|
|
path: '/user',
|
|
|
- component: '../layouts/UserLayout',
|
|
|
|
|
- routes: [{ path: '/user', component: './Welcome' }],
|
|
|
|
|
|
|
+ components: ['../layouts/UserLayout'],
|
|
|
|
|
+ routes: [],
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
path: '/',
|
|
path: '/',
|
|
|
component: '../layouts/BasicLayout',
|
|
component: '../layouts/BasicLayout',
|
|
|
|
|
+ Routes: ['src/pages/Authorized'],
|
|
|
|
|
+ authority: ['admin', 'user'],
|
|
|
routes: [
|
|
routes: [
|
|
|
- { path: '/', redirect: '/welcome' },
|
|
|
|
|
// dashboard
|
|
// dashboard
|
|
|
{
|
|
{
|
|
|
- path: '/welcome',
|
|
|
|
|
|
|
+ path: '/',
|
|
|
name: 'welcome',
|
|
name: 'welcome',
|
|
|
icon: 'smile',
|
|
icon: 'smile',
|
|
|
component: './Welcome',
|
|
component: './Welcome',
|
|
|
},
|
|
},
|
|
|
- {
|
|
|
|
|
- path: 'https://github.com/umijs/umi-blocks/tree/master/ant-design-pro',
|
|
|
|
|
- name: 'more-blocks',
|
|
|
|
|
- icon: 'block',
|
|
|
|
|
- },
|
|
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
- disableRedirectHoist: true,
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * webpack 相关配置
|
|
|
|
|
- */
|
|
|
|
|
- define: {
|
|
|
|
|
- APP_TYPE: process.env.APP_TYPE || '',
|
|
|
|
|
- },
|
|
|
|
|
// Theme for antd
|
|
// Theme for antd
|
|
|
// https://ant.design/docs/react/customize-theme-cn
|
|
// https://ant.design/docs/react/customize-theme-cn
|
|
|
theme: {
|
|
theme: {
|
|
|
- 'primary-color': primaryColor,
|
|
|
|
|
|
|
+ 'primary-color': defaultSettings.primaryColor,
|
|
|
},
|
|
},
|
|
|
externals: {
|
|
externals: {
|
|
|
'@antv/data-set': 'DataSet',
|
|
'@antv/data-set': 'DataSet',
|
|
|
},
|
|
},
|
|
|
|
|
+ // proxy: {
|
|
|
|
|
+ // '/server/api/': {
|
|
|
|
|
+ // target: 'https://preview.pro.ant.design/',
|
|
|
|
|
+ // changeOrigin: true,
|
|
|
|
|
+ // pathRewrite: { '^/server': '' },
|
|
|
|
|
+ // },
|
|
|
|
|
+ // },
|
|
|
ignoreMomentLocale: true,
|
|
ignoreMomentLocale: true,
|
|
|
lessLoaderOptions: {
|
|
lessLoaderOptions: {
|
|
|
javascriptEnabled: true,
|
|
javascriptEnabled: true,
|
|
|
},
|
|
},
|
|
|
|
|
+ disableRedirectHoist: true,
|
|
|
|
|
+ cssLoaderOptions: {
|
|
|
|
|
+ modules: true,
|
|
|
|
|
+ getLocalIdent: (context, localIdentName, localName) => {
|
|
|
|
|
+ if (
|
|
|
|
|
+ context.resourcePath.includes('node_modules') ||
|
|
|
|
|
+ context.resourcePath.includes('ant.design.pro.less') ||
|
|
|
|
|
+ context.resourcePath.includes('global.less')
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return localName;
|
|
|
|
|
+ }
|
|
|
|
|
+ const match = context.resourcePath.match(/src(.*)/);
|
|
|
|
|
+ if (match && match[1]) {
|
|
|
|
|
+ const antdProPath = match[1].replace('.less', '');
|
|
|
|
|
+ const arr = slash(antdProPath)
|
|
|
|
|
+ .split('/')
|
|
|
|
|
+ .map(a => a.replace(/([A-Z])/g, '-$1'))
|
|
|
|
|
+ .map(a => a.toLowerCase());
|
|
|
|
|
+ return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
|
|
|
|
|
+ }
|
|
|
|
|
+ return localName;
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ manifest: {
|
|
|
|
|
+ basePath: '/',
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ chainWebpack: webpackPlugin,
|
|
|
};
|
|
};
|