【问题标题】:How can I define build path in Svelte?如何在 Svelte 中定义构建路径?
【发布时间】:2020-06-24 19:53:53
【问题描述】:

如何在 Svelte 中设置部署路径? 我想在不同路径的网络服务器上使用它,例如

https://example.com/somewhere-else/index.html

但是现在在我运行 npm build 之后,我必须像这样使用它:

https://example.com/index.html

它一定是 rollup.config.js 中的内容,但我找不到。

【问题讨论】:

  • 你在使用 Sapper 吗?
  • 不,只是个苗条。

标签: javascript svelte-3


【解决方案1】:

我想你正在使用标准的 svelte 模板?

https://github.com/sveltejs/template

它创建的包不限于特定路径。您只需要将它们放在适当的路径中并适当地更新 index.html 文件中的链接和脚本标签:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1'>

    <title>Svelte app</title>

    <link rel='icon' type='image/png' href='/favicon.png'><!-- change this -->
    <link rel='stylesheet' href='/global.css'><!-- change this -->
    <link rel='stylesheet' href='/build/bundle.css'><!-- change this -->

    <script defer src='/build/bundle.js'></script><!-- change this -->
</head>

<body>
</body>
</html>

这是否回答了您的问题,还是您的问题更复杂?

【讨论】:

  • 其实是的,它解决了问题。谢谢你:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-26
  • 2021-12-22
  • 2022-08-11
  • 1970-01-01
  • 1970-01-01
  • 2020-12-05
  • 1970-01-01
相关资源
最近更新 更多