Skip to content

Commit

Permalink
fix: 解决 headScripts 链接与 publicPath 不匹配
Browse files Browse the repository at this point in the history
  • Loading branch information
wsafight committed Aug 31, 2024
1 parent 559c01d commit 7f25fe5
Showing 1 changed file with 10 additions and 1 deletion.
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 },
{ src: join(PUBLIC_PATH, 'scripts/loading.js'), async: true },
],
//================ pro 插件配置 =================
presets: ['umi-presets-pro'],
Expand Down

0 comments on commit 7f25fe5

Please sign in to comment.