我已经开始使用 Vite,在开发中一切正常,但是在构建时 没有显示任何内容,因为它构建到根目录
/
这是一个问题,因为我想将其部署到服务器,如 https://example.com/iframes/app
所示,这样我就可以使用 iframe 访问此 url。
所以我将
vite.confi.js
更改为
base: './', // This will ensure that paths are relative to the current directory
build: {
outDir: 'dist',
assetsDir: 'assets',
},
这适用于除了
public
上的所有资产之外的所有内容,在开发中一切都很好,但在构建时浏览器会在服务器的根级别查找它
`https://example.com/asset-on-public.svg`
而不是想要的
`https://example.com/iframes/app/asset-on-public.svg`
有什么想法吗?