My App

Configuration

Configuration

Dex works out of the box with sensible defaults. When you need customization, use dex.config.ts.

Default Structure

By default, Dex expects this layout:

my-app/
├─ web/
│  ├─ pages/           # Route components
│  ├─ layouts/         # Layout components
│  └─ public/          # Static assets
└─ core/               # Generated files

No configuration needed — just start building.

Custom Configuration

Create dex.config.ts in your project root:

import { defineConfig } from 'dex/config'

export default defineConfig({
  // Where pages live
  pagesDir: 'src/pages',
  
  // Where layouts live
  layoutsDir: 'src/layouts',
  
  // Where static assets live
  publicDir: 'static',
  
  // Where generated files go
  outDir: 'src/.generated',
})

Path Precedence

Dex resolves paths in this order (highest to lowest priority):

  1. CLI flags--pagesDir src/views
  2. Config filedex.config.ts values
  3. Defaultsweb/pages, web/layouts, etc.

Available Options

OptionDefaultDescription
pagesDirweb/pagesPage components
layoutsDirweb/layoutsLayout components
publicDirweb/publicStatic assets
outDircoreGenerated files
distDirbuildProduction output

CLI Overrides

Override config values on the command line:

# Override pages directory
bun run dev --pagesDir src/routes

# Override output directory
bun run build --outDir dist

Programmatic Usage

When using Dex functions directly:

import { generateFsRoutes } from '@dex/router'

await generateFsRoutes({
  pagesDir: 'app/routes',
  outTs: 'app/.generated/routes.ts',
})

Passed paths always win over config file values.

Environment Variables

Some features respect environment variables:

VariablePurpose
PORTDev/prod server port (default: 7990)
DEX_API_ONLYSet to 1 for API-only mode
NODE_ENVdevelopment or production

Validation

Dex validates your config and shows helpful errors:

❌ Invalid config: pagesDir must be a string
   → Expected string, got undefined

See Also

On this page