umijs / umi

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

publicPath 配置有问题 #9858

Closed blingStarWang closed 1 year ago

blingStarWang commented 1 year ago

我使用的脚手架是umi4+antdpro 在.umirc.ts中配置publicPath:'./'就报错 把这个配置删除掉就不报错了 之前在写上这个配置的时候并没有报错 求大佬围观一下

`import { defineConfig } from '@umijs/max';

let publicPath = '';

switch (process.env.BUILD_ENV) { case 'dev': publicPath = /; //开发 break; case 'test': publicPath = https://gta-test.gemdale.com; //测试 break; case 'pre': publicPath = https://xxx/pre/xxx; //预发 break; case 'pro': publicPath = https://xxx/master/xxx; //正式 break; default: //开发 publicPath = ./; break; }

export default defineConfig({ antd: {}, theme: { 'primary-color': '#FF6600', }, access: {}, model: {}, initialState: {}, request: {}, publicPath: './', define: { BUILD_ENV: process.env.BUILD_ENV, }, links: [{ rel: 'icon', href: 'https://www.gemdale.com/favicon.ico' }], // 修改title title: '开发者门户', routes: [ { path: '/', redirect: '/home', }, { title: '首页', path: '/home', component: './Home', }, ], proxy: { '/portal': { target: 'https://gta-test.gemdale.com/', changeOrigin: true, pathRewrite: { '^/api': '' }, }, }, npmClient: 'yarn', });`

WechatIMG9
github-actions[bot] commented 1 year ago

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

fz6m commented 1 year ago
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/'

在生产环境下用 ./ 吧,现在不允许在开发环境下用 ./ 当 publicPath

blingStarWang commented 1 year ago

感谢 解决了