duxt build

duxt build#

Build your application for production deployment with optimized assets and compiled server binaries.

Usage#

duxt build [options]

What It Does#

The build command:

  1. Generates Routes - Creates production route mappings
  2. Compiles Frontend - Optimizes and bundles JavaScript/CSS
  3. Compiles Server - Creates native binary (server mode)
  4. Outputs to .output/ - All artifacts in one directory

Options#

OptionDescriptionDefault
--output, -o Output directory .output
--target, -tTarget platformCurrent platform
--all-targetsBuild for all platformsfalse
--verbose, -v Show detailed logs false

Examples#

# Default build
duxt build

# Custom output directory
duxt build --output=dist

# Build for specific platform
duxt build --target=linux-x64

# Build for all platforms
duxt build --all-targets

# Build native desktop app
duxt build desktop

# Desktop debug build
duxt build desktop --debug

Target Platforms#

TargetDescription
linux-x64Linux 64-bit (most servers)
linux-arm64Linux ARM64 (AWS Graviton, etc.)
macos-x64macOS Intel
macos-arm64macOS Apple Silicon
windows-x64Windows 64-bit

Output Structure#

.output/
├── public/                 Static frontend files
│   ├── index.html
│   ├── main.dart.js        Compiled Dart
│   ├── styles.css          Compiled CSS
│   └── assets/             Images, fonts, etc.
├── server-linux-x64        Linux binary
├── server-macos-arm64      macOS binary
└── data.db                 SQLite database (if using ORM)

Build Output#

╭─────────────────────────────────────╮
│  Duxt Production Build              │
╰─────────────────────────────────────╯

→ Generating routes...
  ✓ Found 8 pages

→ Building frontend...
  ✓ Compiled main.dart.js (245 KB)
  ✓ Compiled styles.css (18 KB)

→ Building server...
  ✓ Compiled server-macos-arm64 (12 MB)

✓ Build complete!

  Output:   .output/
  Frontend: .output/public/
  Server:   .output/server-macos-arm64

duxt build desktop#

Build a native desktop application using Tauri v2.

Usage#

duxt build desktop [options]

Options#

OptionDescriptionDefault
--debugBuild without optimizationsfalse

What It Does#

  1. Checks prerequisites (Rust/Cargo)
  2. Auto-installs cargo-tauri if missing
  3. Compiles Tailwind CSS
  4. Generates routes
  5. Runs jaspr build
  6. Runs cargo tauri build

Output#

src-tauri/target/release/bundle/
  macos/            .app bundle
  dmg/              macOS installer
  deb/              Linux package
  msi/              Windows installer

See Desktop Apps for full documentation.


duxt preview#

Preview your production build locally before deploying.

Usage#

duxt preview [options]

Options#

OptionDescriptionDefault
--port, -pFrontend server port4000
--api-portAPI server port3001

Examples#

# Default preview
duxt preview

# Custom port
duxt preview --port=8080

What It Does#

Preview mode:

  1. Serves static files from .output/public/
  2. Runs the compiled server binary
  3. Matches production behavior exactly

This is the final check before deployment.


duxt start#

Start the production server from a built project.

Usage#

duxt start [options]

Options#

OptionDescriptionDefault
--port, -pServer portAuto-finds free port
--open, -o Open browser after starting false

Examples#

# Start on auto-detected free port
duxt start

# Start on specific port
duxt start --port=8080

# Start and open browser
duxt start --open

Production Deployment#

For production, you typically:

  1. Build on CI/CD:

    duxt build --target=linux-x64
    
  2. Copy .output/ to server

  3. Run the binary directly:

    ./server-linux-x64
    

Or use the start command:

duxt start

duxt generate (SSG)#

Generate a fully static site with pre-rendered HTML.

Usage#

duxt generate [options]

Options#

OptionDescriptionDefault
--output, -o Output directory .output/public

When to Use#

Use duxt generate instead of duxt build when:

  • You want static HTML for each route
  • No server-side rendering needed
  • Deploying to static hosts (Netlify, Vercel, GitHub Pages)
  • SEO is critical and content is static

What It Does#

duxt generate
  1. Compiles all pages
  2. Pre-renders each route to HTML
  3. Generates static assets
  4. Outputs everything to .output/public/

Output#

.output/public/
├── index.html              /
├── about/
│   └── index.html          /about
├── blog/
│   ├── index.html          /blog
│   ├── hello-world/
│   │   └── index.html      /blog/hello-world
│   └── second-post/
│       └── index.html      /blog/second-post
├── main.dart.js
└── styles.css

Static Hosting#

Deploy the .output/public/ directory to any static host:

Netlify#

# netlify.toml
[build]
  command = "duxt generate"
  publish = ".output/public"

Vercel#

# vercel.json
{
  "buildCommand": "duxt generate",
  "outputDirectory": ".output/public"
}

GitHub Pages#

# .github/workflows/deploy.yml
- run: duxt generate
- uses: peaceiris/actions-gh-pages@v3
  with:
    publish_dir: .output/public

Comparison#

Featureduxt buildduxt generate
Server requiredYesNo
Dynamic contentYesNo
API routesYesNo
DatabaseYesNo
Pre-rendered HTMLPartialFull
HostingVPS, containersStatic CDN