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

fix: 解决 headScripts 链接与 publicPath 不匹配 #11289

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import routes from './routes';

const { REACT_APP_ENV = 'dev' } = process.env;

/**
* @name 使用公共路径
* @description 部署时的路径,如果部署在非根目录下,需要配置这个变量
* @doc https://umijs.org/docs/api/config#publicpath
*/
const PUBLIC_PATH: string = '/';

export default defineConfig({
/**
* @name 开启 hash 模式
Expand All @@ -15,6 +22,8 @@ export default defineConfig({
*/
hash: true,

publicPath: PUBLIC_PATH,

/**
* @name 兼容性设置
* @description 设置 ie11 不一定完美兼容,需要检查自己使用的所有依赖
Expand Down Expand Up @@ -125,7 +134,7 @@ export default defineConfig({
*/
headScripts: [
// 解决首次加载时白屏的问题
{ src: '/scripts/loading.js', async: true },
afc163 marked this conversation as resolved.
Show resolved Hide resolved
{ src: join(PUBLIC_PATH, 'scripts/loading.js'), async: true },
],
//================ pro 插件配置 =================
presets: ['umi-presets-pro'],
Expand Down
Loading