[]previous and next page

loadDuskConfigFile

Loads dusk.config.(ts|mts|js|mjs) from the project root with Vite's config loader, and validates it.

Loads dusk.config.(ts|mts|js|mjs) from the project root with Vite's config loader, and validates it.

Import#

ts
import { loadDuskConfigFile } from "@shadow-js/dusk/vite";

Signature#

ts
async function loadDuskConfigFile(
  root: string,
  mode: string,
  command: "build" | "serve",
): Promise<LoadedDuskConfig | undefined>

Parameters#

Name Description
root The project root.
mode The Vite mode.
command build or serve.

Returns#

The loaded file, or undefined when the project has none.

Throws#

  • Error when more than one config file exists; TypeError for an invalid file (its path is named).

Examples#

ts
import { loadDuskConfigFile } from "@shadow-js/dusk/vite";
await loadDuskConfigFile(root, "production", "build"); // undefined when the project has no dusk.config file