2019-02-27 11:06:55 +08:00
|
|
|
// https://umijs.org/config/
|
|
|
|
import os from 'os';
|
|
|
|
import pageRoutes from './router.config';
|
|
|
|
import webpackPlugin from './plugin.config';
|
|
|
|
import defaultSettings from '../src/defaultSettings';
|
|
|
|
import slash from 'slash2';
|
|
|
|
|
|
|
|
const { pwa, primaryColor } = defaultSettings;
|
|
|
|
const { NODE_ENV, APP_TYPE, TEST } = process.env;
|
|
|
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
dynamicImport: {
|
|
|
|
loadingComponent: './components/PageLoading/index',
|
|
|
|
webpackChunkName: true,
|
|
|
|
level: 3,
|
|
|
|
},
|
|
|
|
pwa: pwa
|
|
|
|
? {
|
|
|
|
workboxPluginMode: 'InjectManifest',
|
|
|
|
workboxOptions: {
|
|
|
|
importWorkboxFrom: 'local',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: {},
|
|
|
|
...(!TEST && os.platform() === 'darwin'
|
|
|
|
? {
|
|
|
|
dll: {
|
|
|
|
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
|
|
|
|
exclude: ['@babel/runtime'],
|
|
|
|
},
|
|
|
|
hardSource: false,
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
// 针对 preview.pro.ant.design 的 GA 统计代码
|
|
|
|
// 业务上不需要这个
|
|
|
|
if (APP_TYPE === 'site') {
|
|
|
|
plugins.push([
|
|
|
|
'umi-plugin-ga',
|
|
|
|
{
|
|
|
|
code: 'UA-72788897-6',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
// add for transfer to umi
|
2019-03-10 15:01:16 +08:00
|
|
|
// base: '/adsf',
|
|
|
|
// runtimePublicPath: true,
|
2019-03-10 15:02:34 +08:00
|
|
|
base: '/admin-web/',
|
|
|
|
publicPath: '/admin-web/',
|
2019-02-27 11:06:55 +08:00
|
|
|
plugins,
|
|
|
|
define: {
|
|
|
|
APP_TYPE: APP_TYPE || '',
|
|
|
|
},
|
|
|
|
treeShaking: true,
|
|
|
|
targets: {
|
|
|
|
ie: 11,
|
|
|
|
},
|
|
|
|
// 路由配置
|
|
|
|
routes: pageRoutes,
|
|
|
|
// Theme for antd
|
|
|
|
// https://ant.design/docs/react/customize-theme-cn
|
|
|
|
theme: {
|
|
|
|
'primary-color': primaryColor,
|
|
|
|
},
|
|
|
|
externals: {
|
|
|
|
'@antv/data-set': 'DataSet',
|
|
|
|
bizcharts: 'BizCharts',
|
|
|
|
},
|
2019-03-01 14:59:36 +08:00
|
|
|
proxy: {
|
|
|
|
'/admin-api/': {
|
|
|
|
target: 'http://180.167.213.26:18083/',
|
|
|
|
changeOrigin: true,
|
2019-03-06 20:24:14 +08:00
|
|
|
pathRewrite: {},
|
2019-03-01 14:59:36 +08:00
|
|
|
},
|
|
|
|
'/server/api/': {
|
|
|
|
target: 'https://preview.pro.ant.design/',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/server': '' },
|
|
|
|
},
|
|
|
|
},
|
2019-02-27 11:06:55 +08:00
|
|
|
ignoreMomentLocale: true,
|
|
|
|
lessLoaderOptions: {
|
|
|
|
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,
|
|
|
|
};
|