Search code examples
wakanda

How to serve static files in Wakanda v2


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

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?)

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.


Solution

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

    • 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.

    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 })

    Source: https://github.com/Wakanda/wakanda-issues/issues/137