|
1 | 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'; |
| 2 | +import { defineConfig } from "@umijs/max"; |
| 3 | +import defaultSettings from "./defaultSettings"; |
| 4 | +import proxy from "./proxy"; |
| 5 | +import routes from "./routes"; |
6 | 6 |
|
7 |
| -const {REACT_APP_ENV} = process.env; |
| 7 | +const { REACT_APP_ENV = "dev" } = process.env; |
8 | 8 |
|
9 | 9 | export default defineConfig({
|
10 |
| - publicPath: REACT_APP_ENV === 'dist' ? '/scaleph/ui/' : '/', |
11 |
| - outputPath: REACT_APP_ENV === 'dist' ? 'dist-bin' : 'dist', |
12 |
| - history: { |
13 |
| - type: 'hash' |
14 |
| - }, |
| 10 | + /** |
| 11 | + * @name 开启 hash 模式 |
| 12 | + * @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。 |
| 13 | + * @doc https://umijs.org/docs/api/config#hash |
| 14 | + */ |
15 | 15 | hash: true,
|
16 |
| - antd: {}, |
17 |
| - request: {}, |
18 |
| - initialState: {}, |
| 16 | + |
| 17 | + /** |
| 18 | + * @name 兼容性设置 |
| 19 | + * @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖 |
| 20 | + * @doc https://umijs.org/docs/api/config#targets |
| 21 | + */ |
| 22 | + // targets: { |
| 23 | + // ie: 11, |
| 24 | + // }, |
| 25 | + /** |
| 26 | + * @name 路由的配置,不在路由中引入的文件不会编译 |
| 27 | + * @description 只支持 path,component,routes,redirect,wrappers,title 的配置 |
| 28 | + * @doc https://umijs.org/docs/guides/routes |
| 29 | + */ |
| 30 | + // umi routes: https://umijs.org/docs/routing |
| 31 | + routes, |
| 32 | + /** |
| 33 | + * @name 主题的配置 |
| 34 | + * @description 虽然叫主题,但是其实只是 less 的变量设置 |
| 35 | + * @doc antd的主题设置 https://ant.design/docs/react/customize-theme-cn |
| 36 | + * @doc umi 的theme 配置 https://umijs.org/docs/api/config#theme |
| 37 | + */ |
| 38 | + theme: { |
| 39 | + // 如果不想要 configProvide 动态设置主题需要把这个设置为 default |
| 40 | + // 只有设置为 variable, 才能使用 configProvide 动态设置主色调 |
| 41 | + "root-entry-name": "variable", |
| 42 | + }, |
| 43 | + /** |
| 44 | + * @name moment 的国际化配置 |
| 45 | + * @description 如果对国际化没有要求,打开之后能减少js的包大小 |
| 46 | + * @doc https://umijs.org/docs/api/config#ignoremomentlocale |
| 47 | + */ |
| 48 | + ignoreMomentLocale: true, |
| 49 | + /** |
| 50 | + * @name 代理配置 |
| 51 | + * @description 可以让你的本地服务器代理到你的服务器上,这样你就可以访问服务器的数据了 |
| 52 | + * @see 要注意以下 代理只能在本地开发时使用,build 之后就无法使用了。 |
| 53 | + * @doc 代理介绍 https://umijs.org/docs/guides/proxy |
| 54 | + * @doc 代理配置 https://umijs.org/docs/api/config#proxy |
| 55 | + */ |
| 56 | + proxy: proxy[REACT_APP_ENV as keyof typeof proxy], |
| 57 | + /** |
| 58 | + * @name 快速热更新配置 |
| 59 | + * @description 一个不错的热更新组件,更新时可以保留 state |
| 60 | + */ |
| 61 | + fastRefresh: true, |
| 62 | + //============== 以下都是max的插件配置 =============== |
| 63 | + /** |
| 64 | + * @name 数据流插件 |
| 65 | + * @@doc https://umijs.org/docs/max/data-flow |
| 66 | + */ |
19 | 67 | model: {},
|
| 68 | + dva: {}, |
| 69 | + /** |
| 70 | + * 一个全局的初始数据流,可以用它在插件之间共享数据 |
| 71 | + * @description 可以用来存放一些全局的数据,比如用户信息,或者一些全局的状态,全局初始状态在整个 Umi 项目的最开始创建。 |
| 72 | + * @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 |
| 73 | + */ |
| 74 | + initialState: {}, |
| 75 | + /** |
| 76 | + * @name layout 插件 |
| 77 | + * @doc https://umijs.org/docs/max/layout-menu |
| 78 | + */ |
20 | 79 | layout: {
|
21 |
| - // https://umijs.org/zh-CN/plugins/plugin-layout |
22 | 80 | locale: true,
|
23 |
| - siderWidth: 208, |
24 | 81 | ...defaultSettings,
|
25 | 82 | },
|
26 |
| - // https://umijs.org/zh-CN/plugins/plugin-locale |
| 83 | + /** |
| 84 | + * @name 国际化插件 |
| 85 | + * @doc https://umijs.org/docs/max/i18n |
| 86 | + */ |
27 | 87 | locale: {
|
28 |
| - default: 'zh-CN', |
| 88 | + // default zh-CN |
| 89 | + default: "zh-CN", |
29 | 90 | antd: true,
|
30 |
| - title: true, |
| 91 | + // default true, when it is true, will use `navigator.language` overwrite default |
31 | 92 | baseNavigator: true,
|
32 |
| - baseSeparator: '-', |
33 | 93 | },
|
34 |
| - |
35 |
| - targets: { |
36 |
| - chrome: '86', |
37 |
| - }, |
38 |
| - // umi routes: https://umijs.org/docs/routing |
39 |
| - routes, |
| 94 | + /** |
| 95 | + * @name antd 插件 |
| 96 | + * @description 内置了 babel import 插件 |
| 97 | + * @doc https://umijs.org/docs/max/antd#antd |
| 98 | + */ |
| 99 | + antd: {}, |
| 100 | + /** |
| 101 | + * @name 网络请求配置 |
| 102 | + * @description 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。 |
| 103 | + * @doc https://umijs.org/docs/max/request |
| 104 | + */ |
| 105 | + request: {}, |
| 106 | + /** |
| 107 | + * @name 权限插件 |
| 108 | + * @description 基于 initialState 的权限插件,必须先打开 initialState |
| 109 | + * @doc https://umijs.org/docs/max/access |
| 110 | + */ |
40 | 111 | access: {},
|
41 |
| - // Theme for antd: https://ant.design/docs/react/customize-theme-cn |
42 |
| - theme: { |
43 |
| - // 如果不想要 configProvide 动态设置主题需要把这个设置为 default |
44 |
| - // 只有设置为 variable, 才能使用 configProvide 动态设置主色调 |
45 |
| - // https://ant.design/docs/react/customize-theme-variable-cn |
46 |
| - 'root-entry-name': 'variable', |
47 |
| - }, |
48 |
| - ignoreMomentLocale: true, |
49 |
| - proxy: proxy[REACT_APP_ENV || 'dev'], |
50 |
| - manifest: { |
51 |
| - basePath: '/', |
| 112 | + icons: {}, |
| 113 | + //================ pro 插件配置 ================= |
| 114 | + presets: ["umi-presets-pro"], |
| 115 | + mfsu: { |
| 116 | + strategy: "normal", |
52 | 117 | },
|
53 |
| - // Fast Refresh 热更新 |
54 |
| - fastRefresh: true, |
55 |
| - presets: ['umi-presets-pro'], |
56 |
| - dva: {} |
57 |
| - // openAPI: [ |
58 |
| - // { |
59 |
| - // requestLibPath: "import { request } from '@umijs/max'", |
60 |
| - // schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json', |
61 |
| - // projectName: 'swagger', |
62 |
| - // }, |
63 |
| - // ], |
| 118 | + requestRecord: {}, |
| 119 | + esbuildMinifyIIFE: true, |
64 | 120 | });
|
65 |
| - |
66 |
| - |
|
0 commit comments