Files
assetx/antdesign/config/config.ts

192 lines
6.3 KiB
TypeScript
Raw Normal View History

// https://umijs.org/config/
import { join } from 'node:path';
import { defineConfig } from '@umijs/max';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './routes';
const { REACT_APP_ENV = 'dev' } = process.env;
/**
* @name 使
* @description
* @doc https://umijs.org/docs/api/config#publicpath
*/
const PUBLIC_PATH: string = '/';
export default defineConfig({
/**
* @name hash
* @description build hash
* @doc https://umijs.org/docs/api/config#hash
*/
hash: true,
publicPath: PUBLIC_PATH,
/**
* @name
* @description ie11 使
* @doc https://umijs.org/docs/api/config#targets
*/
targets: {
chrome: 91, // Chrome 91 supports BigInt literals (ES2020)
},
/**
* @name
* @description pathcomponentroutesredirectwrapperstitle
* @doc https://umijs.org/docs/guides/routes
*/
// umi routes: https://umijs.org/docs/routing
routes,
/**
* @name
* @description less
* @doc antd的主题设置 https://ant.design/docs/react/customize-theme-cn
* @doc umi theme https://umijs.org/docs/api/config#theme
*/
// theme: { '@primary-color': '#1DA57A' }
/**
* @name moment
* @description js的包大小
* @doc https://umijs.org/docs/api/config#ignoremomentlocale
*/
ignoreMomentLocale: true,
/**
* @name
* @description 访
* @see 使build 使
* @doc https://umijs.org/docs/guides/proxy
* @doc https://umijs.org/docs/api/config#proxy
*/
proxy: proxy[REACT_APP_ENV as keyof typeof proxy],
/**
* @name
* @description state
*/
fastRefresh: true,
//============== 以下都是max的插件配置 ===============
/**
* @name
* @@doc https://umijs.org/docs/max/data-flow
*/
model: {},
/**
*
* @description Umi
* @doc https://umijs.org/docs/max/data-flow#%E5%85%A8%E5%B1%80%E5%88%9D%E5%A7%8B%E7%8A%B6%E6%80%81
*/
initialState: {},
/**
* @name layout
* @doc https://umijs.org/docs/max/layout-menu
*/
title: 'Ant Design Pro',
layout: {
locale: true,
...defaultSettings,
},
/**
* @name moment2dayjs
* @description moment dayjs
* @doc https://umijs.org/docs/max/moment2dayjs
*/
moment2dayjs: {
preset: 'antd',
plugins: ['duration'],
},
/**
* @name
* @doc https://umijs.org/docs/max/i18n
*/
locale: {
// default zh-CN
default: 'zh-CN',
antd: true,
// default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true,
},
/**
* @name antd
* @description babel import
* @doc https://umijs.org/docs/max/antd#antd
*/
antd: {
appConfig: {},
configProvider: {
theme: {
cssVar: true,
token: {
fontFamily: 'AlibabaSans, sans-serif',
},
},
},
},
/**
* @name
* @description axios ahooks useRequest
* @doc https://umijs.org/docs/max/request
*/
request: {},
/**
* @name
* @description initialState initialState
* @doc https://umijs.org/docs/max/access
*/
access: {},
/**
* @name <head> script
* @description <head> script
*/
headScripts: [
// 解决首次加载时白屏的问题
{ src: join(PUBLIC_PATH, 'scripts/loading.js'), async: true },
],
//================ pro 插件配置 =================
presets: ['umi-presets-pro'],
/**
* @name openAPI
* @description openapi serve mock
* @doc https://pro.ant.design/zh-cn/docs/openapi/
* @note swagger-ui-dist: npm install swagger-ui-dist
*/
// openAPI: [
// {
// requestLibPath: "import { request } from '@umijs/max'",
// // 或者使用在线的版本
// // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
// schemaPath: join(__dirname, 'oneapi.json'),
// mock: false,
// },
// {
// requestLibPath: "import { request } from '@umijs/max'",
// schemaPath:
// 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
// projectName: 'swagger',
// },
// ],
mock: false,
/**
* @name mako
* @description 使 mako
* @doc https://umijs.org/docs/api/config#mako
*/
// mako: {}, // 禁用 mako因为 @base-org/account 使用了 mako 不支持的 import attributes 语法
esbuildMinifyIIFE: true,
jsMinifier: 'terser',
chainWebpack(config) {
// @metamask/sdk is listed in package.json (pulled in by wagmi/viem deps)
// but never actually imported in source — alias to empty module to avoid build errors
config.resolve.alias.set('@metamask/sdk', require.resolve('./empty-module.js'));
},
// requestRecord: {}, // 禁用:@umijs/request-record 包缺少 src/runtime/mock.ts
exportStatic: {},
define: {
'process.env.CI': process.env.CI,
'process.env.Auth_URL': process.env.Auth_URL || 'http://localhost:3010',
'process.env.GOOGLE_CLIENT_ID': process.env.GOOGLE_CLIENT_ID || '',
},
});