简体   繁体   English

如何使用 web 服务器部署 Stencil App?

[英]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 docs state:文档state:

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”文件。

Here is the documentation这是文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用docker在Nginx Web服务器上部署Express Web应用程序? - How do I deploy my express web app on nginx web server using docker? 如何在Ubuntu 18.10服务器上部署使用ParcelJS构建的Web应用程序? - How do I deploy my web app built with ParcelJS on my Ubuntu 18.10 server? 如何在使用 nginx 作为 web 服务器构建后部署 svelte kit 应用程序 - How to deploy a svelte kit app after build using nginx as web server 如何在php / apache服务器上部署nodejs app? - How to deploy nodejs app on php/apache server? 如何将我的 ReactJS web 应用程序部署到生产服务器 - How to deploy my ReactJS web application to Production Server 如何在 kube.netes 中无缝部署带有散列资源的 web 应用程序? - How do I seamlessly deploy a web app with hashed resources in kubernetes? 不确定如何使用ExpressJS在生产服务器上启动和部署ReactJS App - Not Sure How to Start and Deploy ReactJS App on Production Server with ExpressJS 如何在Ubuntu服务器上使用Supervisor / Nginx / Gunicorn部署Flask应用 - How to deploy Flask app with Supervisor/Nginx/Gunicorn on Ubuntu server Web服务器和App Server - Web Server and App Server 如何在 nginx web 服务器上托管 reactjs 应用程序? - How to host a reactjs app on nginx web server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM