如何在Wakanda v2中提供静态文件 [英] How to serve static files in 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 onweb
folder, then selectopen in terminal
- Run
npm run build
. Adist
folder is created - Move the
dist
folder into thebackend
project - In studio, set the
dist
folder in thebackend
project as theWebFolder
. Right click on it, then selectset 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屋!