如何在Wakanda v2中提供静态文件 [英] How to serve static files in Wakanda v2

查看:97
本文介绍了如何在Wakanda v2中提供静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Wakanda v2服务器几个月了.我在前端使用Angular(v2 +,而不是angularJS).

I've been using Wakanda v2 server for a few months now. I'm using Angular (v2+ not angularJS) for the front end.

我终于到了要通过Wakanda发布Angular应用程序的地步. (我想我可以像使用Apache一样容易,但是Wakanda有一个Web服务器,为什么不使用它呢?)

I finally got to the point where I want to publish my Angular app through Wakanda. (I suppose I could just as easily use Apache but Wakanda has a web server so why not use it?)

问题是我不知道如何用Wakanda发布应用程序.我尝试将"dist"文件放入Web文件夹,但Wakanda一直说服务不可用".

The problem is I don't know how to publish the app with Wakanda. I tried putting the 'dist' files in the web folder but Wakanda keeps saying "Service Not Available".

任何想法都将不胜感激.

Any thoughts would be much appreciated.

推荐答案

此功能在v2.2版本的辛苦工作和计划​​中. 同时,您可以手动执行以下步骤:

This feature is under hard work and schedule for the v2.2 release. In the meantime, you can do these steps manually:

  • 在终端中打开web文件夹.右键单击web文件夹,然后选择open in terminal
  • 运行npm run build. dist文件夹已创建
  • dist文件夹移至backend项目
  • 在Studio中,将backend项目中的dist文件夹设置为WebFolder.右键单击它,然后选择set as active webfolder.
  • Open the web folder in terminal. Right click on web folder, then select open in terminal
  • Run npm run build. A dist folder is created
  • Move the dist folder into the backend project
  • In studio, set the dist folder in the backend project as the WebFolder. Right click on it, then select set as active webfolder.

角度网址策略可能会出现问题. Wakanda Server无法理解#角度.因此,您可以在/src/app/app.module.ts中添加useHash: true.

You can have issue with the angular URL strategy. The # angular is not understood by Wakanda Server. Therefor, you can add useHash: true in the /src/app/app.module.ts.

RouterModule.forRoot(routes, { useHash: true })

来源: https://github.com/Wakanda/wakanda-issues/issues/137

这篇关于如何在Wakanda v2中提供静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆