[英]How to deploy a Stencil App with a web server?
I'm trying to learn how to deploy a Stencil web app using a web server like Ngnix but I can't make it work on localhost.我正在尝试学习如何使用像 Ngnix 这样的 web 服务器部署 Stencil web 应用程序,但我无法使其在本地主机上运行。 I suspect there is no entry point for the minified build.我怀疑缩小版本没有入口点。
As an example, I'm using the stencil starter app.例如,我使用的是模板入门应用程序。
In my stencil.config.ts file, I have opted-in for the "dist" output target.在我的 stencil.config.ts 文件中,我选择了“dist”output 目标。
outputTargets: [
{
type: 'www',
// comment the following line to disable service workers in production
serviceWorker: null,
baseUrl: 'https://myapp.local/',
},
{
type: 'dist'
},
]
For the minified build I am running the command:对于缩小版本,我正在运行命令:
npm run build -production
The generated "/dist" folder does not contain an index.html file and this prevents me from being able to serve it using Ngnix.生成的“/dist”文件夹不包含 index.html 文件,这使我无法使用 Ngnix 为其提供服务。
The contents of the dist folder dist文件夹的内容
I would expect that the generated "/dist" folder would contain an "index.html" file that could be served as an entry point to a web server.我希望生成的“/dist”文件夹将包含一个“index.html”文件,该文件可以用作 web 服务器的入口点。
What am I doing wrong?我究竟做错了什么?
Is there anything I'm missing?有什么我想念的吗?
The dist
output target is meant for including in existing pages. dist
output 目标用于包含在现有页面中。
To generate a website you can use the www
output target (in the www
folder).要生成网站,您可以使用www
output 目标(在www
文件夹中)。 This will also give you access to website-specific options, like a service worker.这也将使您能够访问特定于网站的选项,例如服务人员。
The www output target type is oriented for webapps and websites, hosted from an http server, which can benefit from prerendering and service workers, such as this very site you're reading. www output 目标类型面向 web 应用程序和网站,由 http 服务器托管,它可以受益于预呈现和服务工作者,例如您正在阅读的这个网站。
For anyone who comes across this in the future, I found the solution.对于将来遇到此问题的任何人,我都找到了解决方案。
I was supposed to use the "/www" folder for deployment as that's the way it's supposed to work for standalone web apps, and it contains an "index.html" file.我应该使用“/www”文件夹进行部署,因为这是它应该用于独立 web 应用程序的方式,并且它包含一个“index.html”文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.