运行 来自 file:// 的 Svelte 应用程序,没有服务器
Run a Svelte app from file:// with no sever
我需要 运行 一个 Svelte 应用程序并且能够在没有服务器的情况下执行它。
对于其他框架,这是可能的,因为它只是 javascript,但我无法找到一种方法来单击我的 index.html 和 运行 我使用 Svelte
构建的应用程序
I need to run a Svelte app and be able to execute it without a server. With other frameworks this is possible as it is just javascript but I can't find a way to just click my index.html and run my app built with Svelte
我会将其分解为两个部分,即构建和执行 svelte 应用程序。
首先,您需要一台计算机 build
Svelte 应用程序,因为它执行汇总(并运行节点服务器)以执行编译,但这不是 OP 要求的...
要解决 Svelte 应用程序的 execution
,您可以在没有 运行 服务器的情况下执行此操作。
请见附件
你从 Svelte create-svelte app generate 命令得到一个 npm run build
,它输出一个 public.html
。
这可用于在 Surge.sh 上托管文件,但是要制作此 "local file friendly",您需要将输出 html 编辑为以下内容(即删除基地 /
).
原始来源index.html
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<script defer src='/build/bundle.js'></script>
决赛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'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='build/bundle.css'>
<script defer src='build/bundle.js'></script>
</head>
<body>
</body>
</html>
我需要 运行 一个 Svelte 应用程序并且能够在没有服务器的情况下执行它。 对于其他框架,这是可能的,因为它只是 javascript,但我无法找到一种方法来单击我的 index.html 和 运行 我使用 Svelte
构建的应用程序I need to run a Svelte app and be able to execute it without a server. With other frameworks this is possible as it is just javascript but I can't find a way to just click my index.html and run my app built with Svelte
我会将其分解为两个部分,即构建和执行 svelte 应用程序。
首先,您需要一台计算机 build
Svelte 应用程序,因为它执行汇总(并运行节点服务器)以执行编译,但这不是 OP 要求的...
要解决 Svelte 应用程序的 execution
,您可以在没有 运行 服务器的情况下执行此操作。
请见附件
你从 Svelte create-svelte app generate 命令得到一个 npm run build
,它输出一个 public.html
。
这可用于在 Surge.sh 上托管文件,但是要制作此 "local file friendly",您需要将输出 html 编辑为以下内容(即删除基地 /
).
原始来源index.html
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<script defer src='/build/bundle.js'></script>
决赛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'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='build/bundle.css'>
<script defer src='build/bundle.js'></script>
</head>
<body>
</body>
</html>