Commit b51cd575 authored by afc163's avatar afc163 Committed by 偏右

🔧 improve pro config.ts

parent b6785541
...@@ -2,7 +2,6 @@ import { IConfig, IPlugin } from 'umi-types'; ...@@ -2,7 +2,6 @@ import { IConfig, IPlugin } from 'umi-types';
import defaultSettings from './defaultSettings'; import defaultSettings from './defaultSettings';
// https://umijs.org/config/ // https://umijs.org/config/
import os from 'os';
import slash from 'slash2'; import slash from 'slash2';
import webpackPlugin from './plugin.config'; import webpackPlugin from './plugin.config';
...@@ -10,8 +9,10 @@ const { pwa, primaryColor } = defaultSettings; ...@@ -10,8 +9,10 @@ const { pwa, primaryColor } = defaultSettings;
// preview.pro.ant.design only do not use in your production ; // preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 // 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[] = [ const plugins: IPlugin[] = [
[ [
'umi-plugin-react', 'umi-plugin-react',
...@@ -41,15 +42,10 @@ const plugins: IPlugin[] = [ ...@@ -41,15 +42,10 @@ const plugins: IPlugin[] = [
}, },
} }
: false, : false,
...(!TEST && os.platform() === 'darwin'
? {
dll: { dll: {
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
exclude: ['@babel/runtime', 'netlify-lambda'], exclude: ['@babel/runtime', 'netlify-lambda'],
}, },
hardSource: false,
}
: {}),
}, },
], ],
[ [
...@@ -61,10 +57,10 @@ const plugins: IPlugin[] = [ ...@@ -61,10 +57,10 @@ const plugins: IPlugin[] = [
autoAddMenu: true, 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([ plugins.push([
'umi-plugin-ga', 'umi-plugin-ga',
{ {
...@@ -73,34 +69,17 @@ if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { ...@@ -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 { export default {
// add for transfer to umi
plugins, 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: { block: {
defaultGitUrl: 'https://github.com/ant-design/pro-blocks', defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
}, },
treeShaking: true, hash: true,
targets: { targets: {
ie: 11, 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: [ routes: [
{ {
path: '/', path: '/',
...@@ -117,18 +96,10 @@ export default { ...@@ -117,18 +96,10 @@ export default {
], ],
}, },
], ],
// 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': primaryColor,
}, },
// proxy: {
// '/server/api/': {
// target: 'https://preview.pro.ant.design/',
// changeOrigin: true,
// pathRewrite: { '^/server': '' },
// },
// },
ignoreMomentLocale: true, ignoreMomentLocale: true,
lessLoaderOptions: { lessLoaderOptions: {
javascriptEnabled: true, javascriptEnabled: true,
...@@ -140,7 +111,7 @@ export default { ...@@ -140,7 +111,7 @@ export default {
context: { context: {
resourcePath: string; resourcePath: string;
}, },
localIdentName: string, _: string,
localName: string, localName: string,
) => { ) => {
if ( if (
...@@ -168,6 +139,14 @@ export default { ...@@ -168,6 +139,14 @@ export default {
manifest: { manifest: {
basePath: '/', basePath: '/',
}, },
uglifyJSOptions,
chainWebpack: webpackPlugin, chainWebpack: webpackPlugin,
/*
proxy: {
'/server/api/': {
target: 'https://preview.pro.ant.design/',
changeOrigin: true,
pathRewrite: { '^/server': '' },
},
},
*/
} as IConfig; } as IConfig;
...@@ -78,7 +78,8 @@ ...@@ -78,7 +78,8 @@
"umi-plugin-ga": "^1.1.3", "umi-plugin-ga": "^1.1.3",
"umi-plugin-pro-block": "^1.3.2", "umi-plugin-pro-block": "^1.3.2",
"umi-plugin-react": "^1.8.2", "umi-plugin-react": "^1.8.2",
"umi-request": "^1.0.7" "umi-request": "^1.0.7",
"umi-types": "^0.3.7"
}, },
"devDependencies": { "devDependencies": {
"@ant-design/colors": "^3.1.0", "@ant-design/colors": "^3.1.0",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment