Skip to content

Feature: make SPA build and served dist directories configurable #711

Description

@shuans

Summary

Please make the AdminForth SPA staging/build directory and the final served dist directory configurable.

Current behavior

In AdminForth 3.13.13, codeInjector.ts:

  • Initializes TMP_DIR from os.tmpdir().
  • Builds the SPA in /tmp/adminforth/<brandSlug>/spa_tmp.
  • Uses the AdminForth package location to derive getServeDir().
  • Copies spa_tmp/dist to that serve directory.
  • The Express adapter serves index.html and assets from codeInjector.getServeDir().

There is currently no documented AdminForth configuration option for either directory.

Setting the standard TMPDIR environment variable can change the temporary root, but it does not make the final served dist directory configurable.

Why this matters

This makes deployments harder in environments where:

  • /tmp is ephemeral, size-limited, or cleaned between releases;
  • build and runtime containers or processes do not share the same /tmp;
  • the application needs build artifacts in an application-owned cache or release directory;
  • the installed package directory is immutable or read-only;
  • a missing temporary cache causes a runtime rebuild and avoidable startup downtime.

Proposed API

Please consider exposing configuration similar to:

customization: {
  spaBuildDir: /var/cache/myapp/adminforth,
  spaServeDir: /var/lib/myapp/adminforth/dist,
}

Alternatively, a single configurable AdminForth SPA root could be provided, with the staging and served paths derived from it.

The implementation should ensure that:

  • existing defaults remain unchanged;
  • bundleNow(), source hashes, dependency installation, and i18n output use the configured build directory;
  • the generated dist is copied to the configured serve directory;
  • the HTTP adapters serve from the same configured serve directory;
  • CI/build-time bundling and runtime startup use identical paths;
  • the option is documented.

A stable environment-variable option would also be useful, but it should cover both the build cache and the served output, not only os.tmpdir().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions