umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.34k stars 2.65k forks source link

[Bug] umi3.5 开启webpack5后页面会自动刷新60s一次 #7504

Closed DODO7419 closed 2 years ago

DODO7419 commented 2 years ago

umi.config

// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
const IS_PROD = [
  'production',
  'prod',
].includes(process.env.NODE_ENV || '');

export default defineConfig({
  base: '/new/',
  publicPath: './',
  hash: true,
  antd: {},
  history: {
    type: 'hash',
  },
  locale: {
    default: 'zh-CN',
    antd: true,
  },
  terserOptions: {
    compress: {
      drop_console: true,
      drop_debugger: true,
    },
  },
  dva: {
    hmr: true,
  },

  layout: {
    // https://umijs.org/zh-CN/plugins/plugin-layout
    locale: true,
    siderWidth: 208,
    ...defaultSettings,
    logo: '/new/icons/icon-512x512.png',
  },
  dynamicImport: {
    loading:
      '@ant-design/pro-layout/es/PageLoading',
  },
  dynamicImportSyntax: {},
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      layout: false,
      routes: [
        {
          path: '/user/login',
          layout: false,
          name: 'login',
          component: './user/Login',
        },
        {
          path: '/user',
          redirect: '/user/login',
        },
        {
          name: 'register-result',
          icon: 'smile',
          path: '/user/register-result',
          component:
            './user/register-result',
        },
        {
          name: 'register',
          icon: 'smile',
          path: '/user/register',
          component: './user/register',
        },
        {
          component: '404',
        },
      ],
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      icon: 'dashboard',
      routes: [
        {
          path: '/dashboard',
          redirect:
            '/dashboard/analysis',
        },
        {
          name: 'analysis',
          icon: 'smile',
          path: '/dashboard/analysis',
          component:
            './dashboard/analysis',
        },
      ],
    },
    {
      name: 'account',
      icon: 'user',
      path: '/account',
      routes: [
        {
          path: '/account',
          redirect: '/account/center',
        },
        {
          name: 'center',
          icon: 'smile',
          path: '/account/center',
          component: './account/center',
        },
        {
          name: 'settings',
          icon: 'smile',
          path: '/account/settings',
          component:
            './account/settings',
        },
      ],
    },

    {
      path: '/',
      redirect: '/dashboard/analysis',
    },
    {
      component: '404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color':
      defaultSettings.primaryColor,
  },
  // esbuild is father build tools
  // https://umijs.org/plugins/plugin-esbuild
  // esbuild: {},
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  // extraBabelPlugins: [
  //   IS_PROD
  //     ? [
  //         'transform-remove-console',
  //         {
  //           exclude: ['error', 'warn'],
  //         },
  //       ]
  //     : '',
  // ],
  nodeModulesTransform: {
    type: 'none',
  },
  mfsu:{},
  webpack5: {},
  exportStatic: {},
  define: {
    BASE_URL:
      '//intelligentsale.imuyuan.com',
  },
});

pagejson配置

{
  "name": "ant-design-pro",
  "version": "5.0.0",
  "private": true,
  "description": "An out-of-box UI solution for enterprise applications",
  "scripts": {
    "analyze": "cross-env ANALYZE=1 umi build",
    "build": "umi build",
    "deploy": "npm run build && npm run gh-pages",
    "serve-dev": "cross-env NODE_OPTIONS=--max_old_space_size=2048 UMI_UI=none UMI_ENV=development  umi dev",
    "serve-test": "cross-env  UMI_ENV=test umi dev",
    "serve-prod": "cross-env  umi dev",
    "build-dev": "cross-env  UMI_ENV=development umi build",
    "build-test": "cross-env  UMI_ENV=test umi build",
    "build-prod": "cross-env  umi build",
    "gh-pages": "gh-pages -d dist",
    "i18n-remove": "pro i18n-remove --locale=zh-CN --write",
    "postinstall": "umi g tmp",
    "lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier && npm run tsc",
    "lint-staged": "lint-staged",
    "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
    "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style",
    "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
    "lint:prettier": "prettier -c --write \"src/**/*\" --end-of-line auto",
    "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less",
    "openapi": "umi openapi",
    "precommit": "lint-staged",
    "prettier": "prettier -c --write \"src/**/*\"",
    "pretest": "node ./tests/beforeTest",
    "test:all": "node ./tests/run-tests.js",
    "test:component": "umi test ./src/components",
    "serve": "umi-serve",
    "tsc": "tsc --noEmit"
  },
  "lint-staged": {
    "**/*.less": "stylelint --syntax less",
    "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",
    "**/*.{js,jsx,tsx,ts,less,md,json}": [
      "prettier --write"
    ]
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 10"
  ],
  "dependencies": {
    "@ant-design/charts": "^0.9.4",
    "@ant-design/icons": "^4.5.0",
    "@ant-design/pro-card": "^1.14.22",
    "@ant-design/pro-descriptions": "^1.6.8",
    "@ant-design/pro-form": "^1.18.3",
    "@ant-design/pro-layout": "^6.15.3",
    "@ant-design/pro-table": "^2.30.8",
    "@antv/data-set": "^0.11.0",
    "@antv/l7": "^2.3.7",
    "@antv/l7-maps": "^2.3.7",
    "@antv/l7-react": "^2.1.9",
    "@umijs/route-utils": "^1.0.36",
    "ahooks": "^2.0.0",
    "antd": "^4.14.0",
    "bizcharts": "^3.5.3-beta.0",
    "bizcharts-plugin-slider": "^2.1.1-beta.1",
    "class-validator": "^0.13.1",
    "classnames": "^2.2.6",
    "gg-editor": "^2.0.2",
    "js-base64": "^3.7.2",
    "js-md5": "^0.7.3",
    "lodash": "^4.17.11",
    "lodash-decorators": "^6.0.0",
    "moment": "^2.25.3",
    "numeral": "^2.0.6",
    "nzh": "^1.0.3",
    "omit.js": "^2.0.2",
    "react": "^17.0.0",
    "react-dev-inspector": "^1.1.1",
    "react-dom": "^17.0.0",
    "react-draggable": "^4.4.4",
    "react-fittext": "^1.0.0",
    "react-helmet-async": "^1.0.4",
    "react-resizable": "^3.0.4",
    "react-router": "^4.3.1",
    "umi": "^3.5.0",
    "umi-serve": "^1.9.10"
  },
  "devDependencies": {
    "@ant-design/pro-cli": "^2.0.2",
    "@types/express": "^4.17.0",
    "@types/history": "^4.7.2",
    "@types/jest": "^26.0.0",
    "@types/js-md5": "^0.4.3",
    "@types/lodash": "^4.14.144",
    "@types/lodash.debounce": "^4.0.6",
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@types/react-helmet": "^6.1.0",
    "@types/react-resizable": "^1.7.4",
    "@umijs/fabric": "^2.6.2",
    "@umijs/openapi": "^1.1.14",
    "@umijs/plugin-blocks": "^2.0.5",
    "@umijs/plugin-esbuild": "^1.0.1",
    "@umijs/plugin-openapi": "^1.2.0",
    "@umijs/preset-ant-design-pro": "^1.2.0",
    "@umijs/preset-dumi": "^1.1.7",
    "@umijs/preset-react": "^1.8.17",
    "@umijs/preset-ui": "^2.2.9",
    "@umijs/yorkie": "^2.0.3",
    "carlo": "^0.9.46",
    "cross-env": "^7.0.0",
    "cross-port-killer": "^1.1.1",
    "detect-installer": "^1.0.1",
    "enzyme": "^3.11.0",
    "eslint": "^7.1.0",
    "express": "^4.17.1",
    "gh-pages": "^3.0.0",
    "jsdom-global": "^3.0.2",
    "lint-staged": "^10.0.0",
    "mockjs": "^1.0.1-beta3",
    "prettier": "^2.3.2",
    "puppeteer-core": "^8.0.0",
    "stylelint": "^13.0.0",
    "typescript": "^4.2.2"
  },
  "engines": {
    "node": ">=10.0.0"
  },
  "gitHooks": {
    "commit-msg": "fabric verify-commit",
    "pre-commit": "lint-staged"
  }
}
DODO7419 commented 2 years ago

已经初步定位到问题,patchRoutes 导致

DODO7419 commented 2 years ago

能不能开放一个动态路由的api

qidasheng369 commented 2 years ago

同求,动态路由的API

soulcm commented 2 years ago

请问下,这个问题有修复了吗,3.5.20版本还是会隔一会儿就重新打包下

liu-jane commented 2 years ago

这个问题解决了吗,没隔一段时自动刷新下真的是头疼

hzl123456 commented 2 years ago

这个问题解决了吗,没隔一段时自动刷新下真的是头疼

webPan commented 2 years ago

是不是热更新还时常失效

soulcm commented 2 years ago

是不是热更新还时常失效

开启 mfsu 后,热更新失效

Mrxyy commented 2 years ago

我也遇到这个问题啦 快点修复吧

kaven85 commented 2 years ago

官方还没修复吗?