vite-patterns

Configure laravel-vite-plugin for asset bundling, HMR, and production builds.

Updated Jan 6, 2023
One-click install
npx skills add https://github.com/pekral/phpstan-rules --skill vite-patterns-pekral
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vite-patterns
Source: https://github.com/pekral/phpstan-rules/tree/main/.claude/skills/vite-patterns
Command: npx skills add https://github.com/pekral/phpstan-rules --skill vite-patterns-pekral

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill resolves the complexity of configuring Vite for Laravel, ensuring seamless asset bundling, HMR, and production builds without the overhead of unnecessary frameworks.

Core Features & Use Cases

  • Vite Configuration: Standardizes the laravel-vite-plugin setup for entrypoints, aliases, and environment variables.
  • Asset Management: Provides patterns for the @vite Blade directive, HMR, and production manifest resolution.
  • Use Case: When setting up a new Laravel project or migrating from Mix, use this Skill to correctly wire your CSS/JS entrypoints, configure Tailwind, and ensure production builds are properly hashed and cache-busted.

Quick Start

Use the vite-patterns skill to configure the laravel plugin in your vite.config.js file for your project entrypoints.

Frequently Asked Questions about vite-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Vite for a Laravel application?

To configure Vite for Laravel, use the official laravel-vite-plugin within your vite.config.js file to define CSS and JS entrypoints. This setup standardizes asset bundling, environment variable handling, and production build pipelines.

What is the best way to migrate from Laravel Mix to Vite?

Migrating from Laravel Mix to Vite requires wiring your CSS and JS entrypoints through the laravel-vite-plugin. You must update your asset management pipeline to use the @vite Blade directive and ensure production builds are properly hashed for cache-busting.

Does Vite work with Livewire and Filament in Laravel?

Yes, Vite works with Livewire and Filament. The configuration patterns ensure seamless integration, allowing you to maintain efficient asset bundling and HMR workflows while using these Laravel生态 ecosystem tools alongside the laravel-vite-plugin.

Why is my Vite HMR not updating in my Laravel project?

Vite HMR issues in Laravel often stem from incorrect entrypoint configuration or Blade directive usage. Ensuring the @vite directive is properly referenced and environment variables are securely handled allows the development server to apply updates correctly.

How do I handle environment variables securely in a Laravel Vite build?

Securely handling environment variables in a Laravel Vite build requires configuring them within the vite.config.js file. The laravel-vite-plugin standardizes this setup, ensuring variables are correctly exposed during HMR and production build pipelines.

When do I need the @vite Blade directive in Laravel asset management?

You need the @vite Blade directive in Laravel asset management to properly load your CSS and JS entrypoints. It resolves the correct paths for HMR during development and the hashed manifest files during production builds.