如何在Sapper中设置基础标签(href属性)?

huangapple go评论108阅读模式
英文:

How to set the base tag href attribute in Sapper?

问题

如何修改Sapper中<base> href属性的值?

根据文档,我尝试了 sapper export --basepath foldername,它(正确地)在__sapper__/export中创建了一个foldername文件夹,但没有更新base标签的href值为预期的"/foldername"值,在创建的index.html文件中。输出仍然是<base href="/" />

我的目标是在GitHub Pages的子文件夹上部署我的SPA。

英文:

How can I modify the value of the <base> href attribute in Sapper ?

As per the documentation, I tried sapper export --basepath foldername which (correctly) creates a foldername folder in __sapper__/export but does not update the base tag href value with the expected "/foldername" value in the created index.html file. The output stays <base href="/" />

My goal is to deploy my SPA on a GitHub Pages subfolder.

答案1

得分: 1

一种方法我刚刚找到是编辑 /src/server.js 并使用第一个参数:

	.use(
		'文件夹名称',  // <-- 在这里
		compression({ threshold: 0 }),
		sirv('static', { dev }),
		sapper.middleware()
	)
英文:

One way I just found is to edit /src/server.js and use the first argument:

	.use(
		&#39;foldername&#39;,  // &lt;-- here
		compression({ threshold: 0 }),
		sirv(&#39;static&#39;, { dev }),
		sapper.middleware()
	)

huangapple
  • 本文由 发表于 2020年1月6日 02:26:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/59602941.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定