Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin-dva] 权限路由依然触发history.listen,model如何按需加载 #172

Open
feibi opened this issue Apr 23, 2020 · 6 comments
Open

Comments

@feibi
Copy link

feibi commented Apr 23, 2020

umi2中页面model是按需加载,权限路由被拦截后,history.listen不会触发。
umi3中页面model是全量加载,权限路由被拦截后,history.listen依然触发。

@hurryhuang1007
Copy link

是的,找了半天怎么按需加载, 发现好像不能啊。。

@xiaohuoni
Copy link
Member

umi@3 的 model 没有按需加载

@hurryhuang1007
Copy link

但是我需要这个功能, 所以umi@3有计划添加这个功能吗

@xiaohuoni
Copy link
Member

@sorrycc cc

@yuanguandong
Copy link

yuanguandong commented Aug 7, 2021

其实主要是model文件虽小,但是数量非常多,首屏加载很耗时,我尝试过codesplit想把这些model合起来,但是发现这样做后虽然index.html里会在加载umi.js后加载models.js, 但页面白屏也不报错

  chunks: [ 'umi','models'],
  chainWebpack: function (config, { env }) {
    config.merge({
      optimization: {
        minimize: env === 'production',
        splitChunks: {
          chunks: 'all',
          minSize: 1,
          minChunks: 1,
          automaticNameDelimiter: '.',
          cacheGroups: {
            vendor: {
              name: 'models',
              test({ resource }: any) {
                const reg1 = /.*[\\/]model.ts/.test(resource)
                const reg2 = /.*[\\/]models\/.*\.ts/.test(resource)
                const merge = reg1 || reg2
                return merge;
              },
              priority: 10,
            },
          },
        },
      },
    });
  },

@CoolBerry
Copy link

same issue :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants