You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.ts 5.1 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // https://umijs.org/config/
  2. import { defineConfig } from '@umijs/max';
  3. import defaultSettings from './defaultSettings';
  4. import proxy from './proxy';
  5. import routes from './routes';
  6. const { REACT_APP_ENV = 'dev' } = process.env;
  7. export default defineConfig({
  8. /**
  9. * @name 开启 hash 模式
  10. * @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。
  11. * @doc https://umijs.org/docs/api/config#hash
  12. */
  13. hash: true,
  14. /**
  15. * @name 兼容性设置
  16. * @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖
  17. * @doc https://umijs.org/docs/api/config#targets
  18. */
  19. // targets: {
  20. // ie: 11,
  21. // },
  22. /**
  23. * @name 路由的配置,不在路由中引入的文件不会编译
  24. * @description 只支持 path,component,routes,redirect,wrappers,title 的配置
  25. * @doc https://umijs.org/docs/guides/routes
  26. */
  27. // umi routes: https://umijs.org/docs/routing
  28. routes,
  29. /**
  30. * @name 主题的配置
  31. * @description 虽然叫主题,但是其实只是 less 的变量设置
  32. * @doc antd的主题设置 https://ant.design/docs/react/customize-theme-cn
  33. * @doc umi 的theme 配置 https://umijs.org/docs/api/config#theme
  34. */
  35. theme: {
  36. // 如果不想要 configProvide 动态设置主题需要把这个设置为 default
  37. // 只有设置为 variable, 才能使用 configProvide 动态设置主色调
  38. // 'root-entry-name': 'variable',
  39. },
  40. /**
  41. * @name moment 的国际化配置
  42. * @description 如果对国际化没有要求,打开之后能减少js的包大小
  43. * @doc https://umijs.org/docs/api/config#ignoremomentlocale
  44. */
  45. ignoreMomentLocale: true,
  46. /**
  47. * @name 代理配置
  48. * @description 可以让你的本地服务器代理到你的服务器上,这样你就可以访问服务器的数据了
  49. * @see 要注意以下 代理只能在本地开发时使用,build 之后就无法使用了。
  50. * @doc 代理介绍 https://umijs.org/docs/guides/proxy
  51. * @doc 代理配置 https://umijs.org/docs/api/config#proxy
  52. */
  53. proxy: proxy[REACT_APP_ENV as keyof typeof proxy],
  54. /**
  55. * @name 快速热更新配置
  56. * @description 一个不错的热更新组件,更新时可以保留 state
  57. */
  58. fastRefresh: true,
  59. //============== 以下都是max的插件配置 ===============
  60. /**
  61. * @name 数据流插件
  62. * @@doc https://umijs.org/docs/max/data-flow
  63. */
  64. model: {},
  65. /**
  66. * 一个全局的初始数据流,可以用它在插件之间共享数据
  67. * @description 可以用来存放一些全局的数据,比如用户信息,或者一些全局的状态,全局初始状态在整个 Umi 项目的最开始创建。
  68. * @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
  69. */
  70. initialState: {},
  71. /**
  72. * @name layout 插件
  73. * @doc https://umijs.org/docs/max/layout-menu
  74. */
  75. title: '智能材料科研平台',
  76. layout: {
  77. ...defaultSettings,
  78. },
  79. // keepalive: [/./],
  80. // tabsLayout: {},
  81. /**
  82. * @name moment2dayjs 插件
  83. * @description 将项目中的 moment 替换为 dayjs
  84. * @doc https://umijs.org/docs/max/moment2dayjs
  85. */
  86. moment2dayjs: {
  87. preset: 'antd',
  88. plugins: ['duration'],
  89. },
  90. /**
  91. * @name 国际化插件
  92. * @doc https://umijs.org/docs/max/i18n
  93. */
  94. locale: {
  95. default: 'zh-CN',
  96. antd: true,
  97. baseNavigator: true,
  98. },
  99. /**
  100. * @name antd 插件
  101. * @description 内置了 babel import 插件
  102. * @doc https://umijs.org/docs/max/antd#antd
  103. */
  104. antd: {
  105. configProvider: {},
  106. appConfig: {},
  107. },
  108. /**
  109. * @name 网络请求配置
  110. * @description 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。
  111. * @doc https://umijs.org/docs/max/request
  112. */
  113. request: {},
  114. /**
  115. * @name 权限插件
  116. * @description 基于 initialState 的权限插件,必须先打开 initialState
  117. * @doc https://umijs.org/docs/max/access
  118. */
  119. access: {},
  120. /**
  121. * @name <head> 中额外的 script
  122. * @description 配置 <head> 中额外的 script
  123. */
  124. headScripts: [
  125. // 解决首次加载时白屏的问题
  126. { src: '/scripts/loading.js', async: true },
  127. { src: '/scripts/resize.js', async: true },
  128. // { src: '/scripts/resize-breakpoint.js', async: true },
  129. ],
  130. // links: [
  131. // {
  132. // href: '/fonts/ALIBABA-PUHUITI-MEDIUM.TTF',
  133. // rel: 'preload',
  134. // as: 'font',
  135. // type: 'font/woff2',
  136. // crossOrigin: 'anonymous',
  137. // },
  138. // ],
  139. //================ pro 插件配置 =================
  140. presets: ['umi-presets-pro'],
  141. /**
  142. * @name openAPI 插件的配置
  143. * @description 基于 openapi 的规范生成serve 和mock,能减少很多样板代码
  144. * @doc https://pro.ant.design/zh-cn/docs/openapi/
  145. */
  146. // openAPI: [],
  147. // mfsu: {
  148. // strategy: 'normal',
  149. // },
  150. requestRecord: {},
  151. icons: {},
  152. lessLoader: {
  153. modifyVars: {
  154. hack: 'true; @import "@/styles/theme.less";',
  155. },
  156. javascriptEnabled: true,
  157. },
  158. valtio: {},
  159. });