tov-template icon indicating copy to clipboard operation
tov-template copied to clipboard

Vite 中的Base修改后会影响到路由

Open woddle opened this issue 1 year ago • 2 comments

将Vite.config.ts中修改了Base 之后,编译后的路由会收到影响

woddle avatar Aug 09 '24 02:08 woddle

设置base:'./'之后打包,生产环境浏览报错index-3XgwbOFl.js:42 Uncaught Error: Invalid path "./" at tokenizePath (index-3XgwbOFl.js:42:10700) at createRouteRecordMatcher (index-3XgwbOFl.js:42:11784) at s (index-3XgwbOFl.js:42:12505) at index-3XgwbOFl.js:42:13935 at Array.forEach () at createRouterMatcher (index-3XgwbOFl.js:42:13924) at createRouter (index-3XgwbOFl.js:42:21047) at index-3XgwbOFl.js:42:28780

ShouJen avatar Aug 27 '24 09:08 ShouJen

把 import Tov from './presets'; 中的 import Router from 'unplugin-vue-router/vite'; 自动路由导入注释,然后去routes中手动配置路由再重新打包即可解决问题

ShouJen avatar Aug 27 '24 10:08 ShouJen

这是设计上的问题,始终保持开发时和生产时 base 的一致性可参考 base 安全的路径解析

image image

markthree avatar Dec 08 '24 03:12 markthree