如何在子目录中托管Svelte应用程序? [英] How can I host a Svelte app in a subdirectory?

查看:66
本文介绍了如何在子目录中托管Svelte应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在域的子目录中托管导出的Svelte项目?想象一下example.com是我的域名,我如何让 src \ routes \ index.svelte 对应于 https://example.com/subdir/ ?

How can I host an exported Svelte project in a subdirectory on my domain? Imagine that example.com is my domain, how can I have src\routes\index.svelte correspond to https://example.com/subdir/?

当我将Svelte导出文件上载到Web服务器的此子目录时,它从控制台读取它找不到

When I upload the Svelte export to this subdirectory of the web server, it reads from the console that it cannot find https://example.com/service-worker.js among other files, which is true, because it's in the /subdir folder. But where can I set the base URL?

推荐答案

您可以在src/server.js中进行设置:

You can set it in src/server.js: https://sapper.svelte.dev/docs#Base_URLs

如果您使用的是sapper export,请记住使用--basepath选项.

Remember to use the --basepath option if you're using sapper export.

这篇关于如何在子目录中托管Svelte应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆