@ -2,7 +2,6 @@ import { IConfig, IPlugin } from 'umi-types';
import defaultSettings from './defaultSettings' ;
// https://umijs.org/config/
import os from 'os' ;
import slash from 'slash2' ;
import webpackPlugin from './plugin.config' ;
@ -10,8 +9,10 @@ const { pwa, primaryColor } = defaultSettings;
// preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process . env ;
const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ;
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION , TEST , NODE_ENV } = process . env ;
const plugins : IPlugin [ ] = [
[
'umi-plugin-react' ,
@ -41,15 +42,10 @@ const plugins: IPlugin[] = [
} ,
}
: false ,
. . . ( ! TEST && os . platform ( ) === 'darwin'
? {
dll : {
include : [ 'dva' , 'dva/router' , 'dva/saga' , 'dva/fetch' ] ,
exclude : [ '@babel/runtime' , 'netlify-lambda' ] ,
} ,
hardSource : false ,
}
: { } ) ,
dll : {
include : [ 'dva' , 'dva/router' , 'dva/saga' , 'dva/fetch' ] ,
exclude : [ '@babel/runtime' , 'netlify-lambda' ] ,
} ,
} ,
] ,
[
@ -61,10 +57,10 @@ const plugins: IPlugin[] = [
autoAddMenu : true ,
} ,
] ,
] ; // 针对 preview.pro.ant.design 的 GA 统计代码
// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
] ;
if ( ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ) {
// 针对 preview.pro.ant.design 的 GA 统计代码
if ( isAntDesignProPreview ) {
plugins . push ( [
'umi-plugin-ga' ,
{
@ -73,34 +69,17 @@ if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
] ) ;
}
const uglifyJSOptions =
NODE_ENV === 'production'
? {
uglifyOptions : {
// remove console.* except console.error
compress : {
drop_console : true ,
pure_funcs : [ 'console.error' ] ,
} ,
} ,
}
: { } ;
export default {
// add for transfer to umi
plugins ,
define : {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION :
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '' , // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
} ,
block : {
defaultGitUrl : 'https://github.com/ant-design/pro-blocks' ,
} ,
treeShaking : true ,
hash : true ,
targets : {
ie : 11 ,
} ,
devtool : ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION ? 'source-map' : false ,
// 路由配置
devtool : isAntDesignProPreview ? 'source-map' : false ,
// umi routes: https://umijs.org/zh/guide/router.html
routes : [
{
path : '/' ,
@ -117,18 +96,10 @@ export default {
] ,
} ,
] ,
// Theme for antd
// https://ant.design/docs/react/customize-theme-cn
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme : {
'primary-color' : primaryColor ,
} ,
// proxy: {
// '/server/api/': {
// target: 'https://preview.pro.ant.design/',
// changeOrigin: true,
// pathRewrite: { '^/server': '' },
// },
// },
ignoreMomentLocale : true ,
lessLoaderOptions : {
javascriptEnabled : true ,
@ -140,7 +111,7 @@ export default {
context : {
resourcePath : string ;
} ,
localIdentName : string ,
_ : string ,
localName : string ,
) = > {
if (
@ -168,6 +139,14 @@ export default {
manifest : {
basePath : '/' ,
} ,
uglifyJSOptions ,
chainWebpack : webpackPlugin ,
/ *
proxy : {
'/server/api/' : {
target : 'https://preview.pro.ant.design/' ,
changeOrigin : true ,
pathRewrite : { '^/server' : '' } ,
} ,
} ,
* /
} as IConfig ;