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

[Bug] publicPath为自定义协议时,开启自动分包后,打包出的index.html中的framework.js导入方式不对 #12670

Closed
ShirasawaSama opened this issue Aug 30, 2024 · 1 comment · Fixed by #12704

Comments

@ShirasawaSama
Copy link

ShirasawaSama commented Aug 30, 2024

What happens?

相关 Issue: #10971 [Bug] window.publicPath 为非标准链接时,替换会出现bug。

publicPath 为自定义协议时,开启自动代码分包后,打包出的 index.html 中的 framework.js 导入方式不对。

需求原因:应用是在自己开发的环境上跑的,采用了特殊的静态资源打包方式,不从网络读取,而是通过自定义协议加速读取。

第一次出现问题的版本: 4.0.35, 因此 4.0.34 之前的版本是正常的

可疑的 commit: 34bf7ef#diff-26880db4275301a0f7420e3f739568abf3eb791c87cfbe6553d5abed8872d1f9

实际结果

image

预期结果

image

Mini Showcase Repository(REQUIRED)

https://github.com/ShirasawaSama/umi-custom-protocol-public-path-bug

特意把 dist 目录 push 上来了, 可以看 dist 目录里面的 index.html

How To Reproduce

config.ts:

import { defineConfig } from 'umi';

export default defineConfig({
  publicPath: 'myprotocol://example.com/foo/',
  codeSplitting: {
    jsStrategy: 'granularChunks',
  },
})

然后打包生产环境包,即可复现

Context

  • Umi Version: 4.3.18
  • Node Version: 20.15.1
  • Platform: MacOS 14.4
@xierenyuan
Copy link
Member

https://github.com/umijs/umi/blob/master/packages/server/src/scripts.ts#L18 应该是判断非 url 了、自定义协议需要考虑下如何去兼容

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

Successfully merging a pull request may close this issue.

2 participants