소스 검색

fix: 报错修复

lanjianrong 5 년 전
부모
커밋
328ad45f2a

+ 48 - 1
config/config.js

@@ -31,6 +31,12 @@ export default defineConfig({
   targets: {
     ie: 11
   },
+  terserOptions: {
+    compress: {
+      drop_console: REACT_APP_ENV === 'prod' ? true : false,
+      drop_debugger: REACT_APP_ENV === 'prod' ? true : false
+    }
+  },
   // umi routes: https://umijs.org/docs/routing
   routes,
   // Theme for antd: https://ant.design/docs/react/customize-theme-cn
@@ -46,6 +52,9 @@ export default defineConfig({
   exportStatic: {},
   esbuild: {},
   fastRefresh: {},
+  nodeModulesTransform: {
+    type: 'none' // 提升编译速度加速,加速
+  },
   extraBabelPlugins: [
     '@babel/plugin-proposal-nullish-coalescing-operator',
     '@babel/plugin-proposal-optional-chaining',
@@ -53,13 +62,44 @@ export default defineConfig({
       'import',
       {
         libraryName: '@icon-park/react',
-        libraryDirectory: 'es/all',
+        libraryDirectory: 'es/icons',
         camel2DashComponentName: false
       }
     ]
   ],
   chainWebpack(config, { env }) {
     config.plugin('windicss').use(windicss)
+    config.merge({
+      optimization: {
+        minimize: true,
+        splitChunks: {
+          chunks: 'async',
+          minSize: 30000,
+          minChunks: 2,
+          automaticNameDelimiter: '.',
+          cacheGroups: {
+            vendor: {
+              name: 'vendors',
+              test: /^.*node_modules[\\/](!lodash|antd).*$/,
+              chunks: 'all',
+              priority: 10
+            },
+            antd: {
+              name: 'antd',
+              test: /[\\/]node_modules[\\/]antd[\\/]/,
+              chunks: 'all',
+              priority: 9
+            },
+            lodash: {
+              name: 'lodash',
+              test: /[\\/]node_modules[\\/]lodash[\\/]/,
+              chunks: 'all',
+              priority: -2
+            }
+          }
+        }
+      }
+    })
     if (env === 'production') {
       config.plugin('compression-webpack-plugin').use(
         new CompressionWebpackPlugin({
@@ -71,5 +111,12 @@ export default defineConfig({
         })
       )
     }
+    //过滤掉momnet的那些不使用的国际化文件
+    config
+      .plugin('replace')
+      .use(require('webpack').ContextReplacementPlugin)
+      .tap(() => {
+        return [/moment[/\\]locale$/, /zh-cn/]
+      })
   }
 })

+ 2 - 3
package.json

@@ -65,13 +65,10 @@
     "react": "^17.0.1",
     "react-dom": "^17.0.1",
     "react-helmet-async": "^1.0.4",
-    "react-transition-group": "^4.4.1",
     "umi": "^3.2.14",
-    "umi-request": "^1.0.8",
     "use-merge-value": "^1.0.1"
   },
   "devDependencies": {
-    "compression-webpack-plugin": "4.0.1",
     "@ant-design/pro-cli": "^1.0.18",
     "@babel/plugin-proposal-optional-chaining": "^7.13.12",
     "@types/classnames": "^2.2.7",
@@ -94,6 +91,7 @@
     "babel-plugin-import": "^1.13.3",
     "carlo": "^0.9.46",
     "chalk": "^4.0.0",
+    "compression-webpack-plugin": "4.0.1",
     "cross-env": "^7.0.0",
     "cross-port-killer": "^1.1.1",
     "detect-installer": "^1.0.1",
@@ -112,6 +110,7 @@
     "puppeteer-core": "^5.0.0",
     "stylelint": "^13.9.0",
     "typescript": "^4.0.3",
+    "webpack": "^5.40.0",
     "windicss": "3.0.12",
     "windicss-webpack-plugin": "1.0.0"
   },

+ 1 - 0
src/global.jsx

@@ -4,6 +4,7 @@ import { useIntl } from 'umi'
 import defaultSettings from '../config/defaultSettings'
 import './basic/css/common.scss'
 import 'windi.css'
+import '@icon-park/react/styles/index.less'
 
 const { pwa } = defaultSettings
 const isHttps = document.location.protocol === 'https:' // if pwa is true

+ 0 - 1
src/pages/Customer/Company/components/AddCompany/index.jsx

@@ -3,7 +3,6 @@ import { Form, Row, Col, Button } from 'antd'
 import LazyCascader from '@/components/LazyCascader'
 import { ModalForm, ProFormSelect, ProFormText } from '@ant-design/pro-form'
 import { connect } from 'dva'
-import SvgIcon from '@/components/SvgIcon'
 import { Plus } from '@icon-park/react'
 
 const AddCompany = props => {

+ 1 - 1
src/pages/Customer/Company/components/CompanyDetail/CompanyForm.jsx

@@ -3,7 +3,7 @@ import { Row, Col, Tooltip } from 'antd'
 import EditableForm from '@/components/EditableForm'
 import PersonLabel from '../PersonLabel'
 import { TagTypeEnum, TagDataTypeEnum, LabelModeType } from '../PersonLabel/const'
-import { Add, Down, Check } from '@icon-park/react'
+import { Add } from '@icon-park/react'
 import { connect } from 'umi'
 
 const CompanyForm = props => {