mix vitex.install (Vitex v0.2.4)

View Source

Installs and configures Phoenix Vite in a Phoenix application using Igniter.

This installer:

  1. Creates vite.config.js with appropriate configuration
  2. Updates package.json with Vite dependencies and scripts
  3. Adds the Vite watcher to the development configuration
  4. Updates the root layout template to use Vite helpers
  5. Creates or updates asset files for Vite

Usage

$ mix vitex.install

Options

--ssr                Enable Server-Side Rendering support
--tls                Enable automatic TLS certificate detection
--react              Enable React Fast Refresh support
--typescript         Enable TypeScript support
--inertia            Enable Inertia.js support (automatically enables React)
--shadcn             Enable shadcn/ui component library (requires --typescript and either --react or --inertia)
--base-color         Base color for shadcn/ui theme (neutral,gray, zinc, stone, slate) - defaults to neutral
--bun                Use Bun as the package manager instead of npm
--yes                Don't prompt for confirmations

Package Manager Support

Vitex supports two approaches for package management:

  1. System Package Managers (npm, pnpm, yarn): Uses whatever is installed on the system
  2. Elixir-Managed Bun (--bun flag): Uses the Elixir bun package to download and manage the bun executable

The --bun option is special because:

  • It adds a Mix dependency for bun
  • The bun executable is managed at _build/bun
  • It can use Bun workspaces for Phoenix JS dependencies
  • Mix tasks handle the bun installation lifecycle

Summary

Functions

create_vite_config(igniter)

maybe_add_bun_dep(igniter)

maybe_add_inertia_dep(igniter)

maybe_setup_bun_config(igniter)

maybe_setup_inertia(igniter)

maybe_setup_shadcn(igniter)

remove_old_watchers(igniter)

setup_assets(igniter)

setup_html_helpers(igniter)

setup_watcher(igniter)

setup_watcher_for_system_package_managers(igniter)

update_mix_aliases(igniter)

update_mix_aliases_for_system_package_managers(igniter)

update_package_json(igniter)

update_root_layout(igniter)

update_vendor_imports(igniter)