or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

asset-management.mdindex.mdinertia-helpers.mdplugin-configuration.md
tile.json

plugin-configuration.mddocs/

Plugin Configuration

Core Laravel Vite plugin configuration and setup options for integrating Vite with Laravel applications.

Capabilities

Laravel Plugin Factory

Creates the main Laravel Vite plugin with optional additional plugins for full page reload functionality.

/**
 * Laravel plugin for Vite
 * @param config - Configuration object or entry point paths
 * @returns Array containing Laravel plugin and optional full reload plugins
 */
export default function laravel(
  config: string | string[] | PluginConfig
): [LaravelPlugin, ...Plugin[]];

Usage Examples:

import laravel from "laravel-vite-plugin";

// Simple string input
export default defineConfig({
  plugins: [laravel("resources/js/app.js")]
});

// Array of inputs
export default defineConfig({
  plugins: [laravel([
    "resources/css/app.css",
    "resources/js/app.js"
  ])]
});

// Full configuration object
export default defineConfig({
  plugins: [laravel({
    input: "resources/js/app.js",
    publicDirectory: "public",
    buildDirectory: "build",
    ssr: "resources/js/ssr.js",
    refresh: true
  })]
});

Plugin Configuration Interface

Complete configuration options for the Laravel Vite plugin.

interface PluginConfig {
  /** The path or paths of the entry points to compile */
  input: Rollup.InputOption;
  /** Laravel's public directory (default: 'public') */
  publicDirectory?: string;
  /** The public subdirectory where compiled assets should be written (default: 'build') */
  buildDirectory?: string;
  /** The path to the "hot" file (default: `${publicDirectory}/hot`) */
  hotFile?: string;
  /** The path of the SSR entry point */
  ssr?: Rollup.InputOption;
  /** The directory where the SSR bundle should be written (default: 'bootstrap/ssr') */
  ssrOutputDirectory?: string;
  /** Configuration for performing full page refresh on blade file changes (default: false) */
  refresh?: boolean | string | string[] | RefreshConfig | RefreshConfig[];
  /** Utilise the Herd or Valet TLS certificates (default: null) */
  detectTls?: string | boolean | null;
  /** @deprecated Use "detectTls" instead. Legacy TLS certificate detection (default: null) */
  valetTls?: string | boolean | null;
  /** Transform the code while serving */
  transformOnServe?: (code: string, url: DevServerUrl) => string;
}

Refresh Configuration

Configuration for full page reload functionality when blade templates or other files change.

interface RefreshConfig {
  /** Paths to watch for changes */
  paths: string[];
  /** vite-plugin-full-reload configuration options */
  config?: FullReloadConfig;
}

type DevServerUrl = `${'http' | 'https'}://${string}:${number}`;

Refresh Configuration Examples:

// Enable default paths
refresh: true

// Single path
refresh: "resources/views/**/*.blade.php"

// Multiple paths
refresh: ["resources/views/**", "routes/**"]

// Full configuration
refresh: {
  paths: ["resources/views/**/*.blade.php"],
  config: { delay: 300 }
}

// Multiple configurations
refresh: [
  {
    paths: ["resources/views/**"],
    config: { delay: 100 }
  },
  {
    paths: ["routes/**"],
    config: { delay: 200 }
  }
]

Laravel Plugin Interface

Extended Vite plugin interface with Laravel-specific configuration method.

interface LaravelPlugin extends Plugin {
  config: (config: UserConfig, env: ConfigEnv) => UserConfig;
}

Default Refresh Paths

Pre-configured paths that are automatically watched when refresh: true is specified.

/**
 * Default paths for full page refresh functionality
 * Includes Laravel-specific directories like Livewire components,
 * View components, language files, views, and routes
 */
export const refreshPaths: string[];

The default paths include:

  • app/Livewire/** - Livewire components
  • app/View/Components/** - Blade view components
  • lang/** - Language files
  • resources/lang/** - Resource language files
  • resources/views/** - Blade template files
  • routes/** - Route definition files

Configuration Validation

The plugin performs automatic validation and normalization of configuration options:

  • Input validation: Ensures input option is provided and not empty
  • Directory validation: Prevents empty publicDirectory or buildDirectory values
  • Path normalization: Removes leading/trailing slashes from directory paths
  • SSR defaults: Uses main input as SSR entry point if ssr is not specified
  • Refresh normalization: Converts simple refresh configurations to standardized format

Environment Integration

The plugin automatically detects and integrates with various Laravel development environments:

  • Laravel Sail: Configures server host, port, and CORS for containerized development
  • Herd/Valet: Automatically detects and uses TLS certificates for HTTPS development
  • Environment Variables: Reads configuration from Laravel environment files
  • Production Checks: Prevents running development server in production environments