.umirc.ts 是 umi3 配置,umi4 把项目的配置都移动到 config目录下进行管理

.umirc.ts

  1. import { defineConfig } from 'umi';
  2. import { join } from 'path';
  3. import aliyunTheme from '@ant-design/aliyun-theme';
  4. import routes from './config/routes';
  5. import dev from './config/dev';
  6. import prod from './config/prod';
  7. import proxy from './config/proxy';
  8. // import qiankun from './config/qiankun';
  9. // const { REACT_APP_ENV } = process.env;
  10. console.log(process.env.NODE_ENV);
  11. const envConfig = 'development' === process.env.NODE_ENV ? dev : prod;
  12. export default defineConfig({
  13. ...envConfig,
  14. // title: false,
  15. routes,
  16. // qiankun,
  17. proxy: proxy[REACT_APP_ENV || 'dev'],
  18. antd: {},
  19. // mfsu: {},
  20. webpack5: {}, // 使用webpack 5
  21. // dynamicImport: {},
  22. fastRefresh: {},
  23. dva: {
  24. hmr: true,
  25. },
  26. dva: {
  27. hmr: true,
  28. },
  29. hash: false,
  30. layout: {
  31. // https://umijs.org/zh-CN/plugins/plugin-layout
  32. locale: true,
  33. siderWidth: 208,
  34. ...layout,
  35. },
  36. locale: {
  37. default: 'zh-CN',
  38. antd: true,
  39. // default true, when it is true, will use `navigator.language` overwrite default
  40. baseNavigator: true,
  41. },
  42. chunks: ['vendors', 'umi'],
  43. nodeModulesTransform: {
  44. type: 'none',
  45. },
  46. // https://ant.design/docs/react/customize-theme-cn
  47. theme: {
  48. '@font-size-base': '14px',
  49. 'primary-color': 'rgb(75, 12, 255)',
  50. 'root-entry-name': 'default',
  51. ...aliyunTheme,
  52. },
  53. dynamicImport: {
  54. loading: '@ant-design/pro-layout/es/PageLoading',
  55. },
  56. manifest: {
  57. basePath: '/',
  58. },
  59. ignoreMomentLocale: true,
  60. targets: {
  61. ie: 11,
  62. },
  63. // 以下配置,有些已经废弃,请参考文档
  64. nodeModulesTransform: { type: 'none' },
  65. // mfsu: {},
  66. webpack5: {},
  67. exportStatic: {},
  68. // Fast Refresh 热更新
  69. fastRefresh: {},
  70. // https://umijs.org/plugins/plugin-esbuild
  71. esbuild: {},
  72. openAPI: [
  73. {
  74. requestLibPath: "import { request } from 'umi'",
  75. // 或者使用在线的版本
  76. // schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
  77. schemaPath: join(__dirname, 'oneapi.json'),
  78. mock: false,
  79. },
  80. {
  81. requestLibPath: "import { request } from 'umi'",
  82. schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
  83. projectName: 'swagger',
  84. },
  85. ],
  86. });

theme

自定义主题不生效问题,禁用 mfsu
image.png

ant-design-pro5.0

  1. {
  2. "name": "ant-design-pro",
  3. "version": "5.0.0",
  4. "private": true,
  5. "description": "An out-of-box UI solution for enterprise applications",
  6. "scripts": {
  7. "analyze": "cross-env ANALYZE=1 umi build",
  8. "build": "umi build",
  9. "deploy": "npm run build && npm run gh-pages",
  10. "dev": "npm run start:dev",
  11. "gh-pages": "gh-pages -d dist",
  12. "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
  13. "postinstall": "umi g tmp",
  14. "lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier && npm run tsc",
  15. "lint-staged": "lint-staged",
  16. "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
  17. "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
  18. "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
  19. "lint:prettier": "prettier -c --write \"src/**/*\" --end-of-line auto",
  20. "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
  21. "openapi": "umi openapi",
  22. "precommit": "lint-staged",
  23. "prettier": "prettier -c --write \"src/**/*\"",
  24. "serve": "umi-serve",
  25. "start": "cross-env UMI_ENV=dev umi dev",
  26. "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev",
  27. "start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev",
  28. "start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev",
  29. "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev umi dev",
  30. "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev umi dev",
  31. "pretest": "node ./tests/beforeTest",
  32. "test": "umi test",
  33. "test:all": "node ./tests/run-tests.js",
  34. "test:component": "umi test ./src/components",
  35. "tsc": "tsc --noEmit"
  36. },
  37. "dependencies": {
  38. "@ant-design/aliyun-theme": "0.0.4",
  39. "@ant-design/icons": "^4.5.0",
  40. "@ant-design/pro-descriptions": "^1.9.0",
  41. "@ant-design/pro-form": "^1.43.0",
  42. "@ant-design/pro-layout": "^6.26.0",
  43. "@ant-design/pro-table": "^2.56.0",
  44. "@umijs/route-utils": "^2.0.3",
  45. "antd": "^4.17.3",
  46. "classnames": "^2.2.6",
  47. "lodash": "^4.17.11",
  48. "moment": "^2.25.3",
  49. "omit.js": "^2.0.2",
  50. "rc-menu": "^9.0.13",
  51. "rc-util": "^5.14.0",
  52. "react": "^17.0.2",
  53. "react-dev-inspector": "^1.1.1",
  54. "react-dom": "^17.0.2",
  55. "react-helmet-async": "^1.0.4",
  56. "umi": "^3.5.0",
  57. "umi-serve": "^1.9.10"
  58. },
  59. "devDependencies": {
  60. "@ant-design/pro-cli": "^2.0.2",
  61. "@types/express": "^4.17.0",
  62. "@types/history": "^4.7.2",
  63. "@types/jest": "^26.0.0",
  64. "@types/lodash": "^4.14.144",
  65. "@types/react": "^17.0.0",
  66. "@types/react-dom": "^17.0.0",
  67. "@types/react-helmet": "^6.1.0",
  68. "@umijs/fabric": "^2.6.2",
  69. "@umijs/openapi": "^1.3.0",
  70. "@umijs/plugin-blocks": "^2.0.5",
  71. "@umijs/plugin-esbuild": "^1.0.1",
  72. "@umijs/plugin-openapi": "^1.2.0",
  73. "@umijs/preset-ant-design-pro": "^1.2.0",
  74. "@umijs/preset-dumi": "^1.1.7",
  75. "@umijs/preset-react": "^1.8.17",
  76. "@umijs/yorkie": "^2.0.3",
  77. "carlo": "^0.9.46",
  78. "cross-env": "^7.0.0",
  79. "cross-port-killer": "^1.1.1",
  80. "detect-installer": "^1.0.1",
  81. "enzyme": "^3.11.0",
  82. "eslint": "^7.1.0",
  83. "express": "^4.17.1",
  84. "gh-pages": "^3.0.0",
  85. "jsdom-global": "^3.0.2",
  86. "lint-staged": "^10.0.0",
  87. "mockjs": "^1.0.1-beta3",
  88. "prettier": "^2.3.2",
  89. "puppeteer-core": "^8.0.0",
  90. "stylelint": "^13.0.0",
  91. "swagger-ui-react": "^3.52.3",
  92. "typescript": "^4.2.2"
  93. },
  94. "lint-staged": {
  95. "**/*.less": "stylelint --syntax less",
  96. "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
  97. "**/*.{js,jsx,tsx,ts,less,md,json}": [
  98. "prettier --write"
  99. ]
  100. },
  101. "browserslist": [
  102. "> 1%",
  103. "last 2 versions",
  104. "not ie <= 10"
  105. ],
  106. "engines": {
  107. "node": ">=10.0.0"
  108. },
  109. "gitHooks": {
  110. "commit-msg": "fabric verify-commit"
  111. }
  112. }