Class: Wurk::DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wurk/dashboard_controller.rb

Overview

Serves the SPA shell. Everything else is JSON from ApiController.

Production: returns the precompiled index.html shipped in vendor/assets/dashboard. The release pipeline (‘frontend:build` →`gem build`) writes both that file and the wurk-manifest.json validated at engine boot.

Development: when WURK_VITE_DEV=1 is set, fetches the shell from the Vite dev server (default :5173) so contributors get HMR without rebuilding the bundle on every change.

Direct Known Subclasses

ExtensionsController

Constant Summary collapse

VITE_DEV_HOST =

Vite serves the dev shell under its ‘base` (vite.config.ts), which is the same path the engine mounts assets at — so derive these from AssetMount::PREFIX to keep the Ruby side in lockstep. Fetching the server root instead returns Vite’s “did you mean /wurk-assets/” hint page, not the shell (issue #181).

'http://localhost:5173'
VITE_ASSET_BASE =

“/wurk-assets/”

"#{::Wurk::Engine::AssetMount::PREFIX}/".freeze
VITE_DEV_URL =
"#{VITE_DEV_HOST}#{VITE_ASSET_BASE}".freeze
INDEX_REL_PATH =
['vendor', 'assets', 'dashboard', 'index.html'].freeze

Instance Method Summary collapse

Instance Method Details

#indexObject



28
29
30
# File 'app/controllers/wurk/dashboard_controller.rb', line 28

def index
  render layout: false, html: spa_html.html_safe
end