UI
Set up the app-side switches that let an ApiHug application generate and serve a Vue UI module.
This page explains the app-side configuration that connects an ApiHug application module to a generated Vue UI module.
Read this page when you already understand the basic Vue UI output and now need to:
Use this setup when your project keeps backend runtime and frontend UI in separate modules, but you still want ApiHug to coordinate generation and packaging between them.
In {app}/build.gradle, enable the frontend stub output:
hopeStub {
enableFrontVue = true
}
Create or update {app}/ui.json:
{
"projectDir": "../good-app-ui"
}
This file tells the app module where the UI project lives relative to the backend module.
In the ApiHug workflow:
proto defines the contractThe app module is therefore the bridge between contract output and frontend generation policy.
After enabling the app-side configuration, run the stub/build sequence from the app module:
./gradlew.bat {app}:clean stub build -x test -x stubTest
Typical generated output includes:
| File | Purpose |
|---|---|
{app}/build.gradle | Enables Vue generation from the app module |
{app}/ui.json | Points to the real UI workspace |
{ui}/router.json | Defines auto-route generation rules inside the UI module |
ApiHug's UI workflow assumes route generation happens in the UI module, not inside the backend runtime.
A typical router.json shape looks like this:
{
"items": [
{
"moduleDir": "apps/web1"
},
{
"moduleDir": "apps/web2"
}
]
}
Use this when one UI repository contains multiple independently generated application entries.
At runtime, the backend module usually serves the built UI assets and forwards SPA routes to index.html.
Two parts matter:
dist into the backend static resources directoryExample resource copy hook:
tasks.register('copyUIResources', Copy) {
dependsOn project(':good-app-ui').tasks.named('build')
from project(':good-app-ui').layout.projectDirectory.dir('dist')
into "${layout.buildDirectory.get()}/resources/main/static"
}
tasks.named('processResources') {
dependsOn 'copyUIResources'
}
Example SPA forwarding rule:
SpaPathChecker DEFAULT =
path ->
!path.startsWith("/api")
&& !path.startsWith("/management")
&& !path.startsWith("/v3/api-docs")
&& !path.startsWith("/hope/meta")
&& !path.startsWith("/h2-console")
&& !path.contains(".")
&& path.matches("/(.*)");
This keeps API traffic on backend routes while normal browser navigation continues through the SPA entrypoint.
After this configuration is in place, the app module becomes the stable handoff point between ApiHug contract generation and a real Vue UI workspace, instead of leaving frontend generation as an ad-hoc manual step.