agentleFS
AnyOrgNameAnyOrgName/php-skills/skills/laravel/vite/SKILL.md

vite

Skill4 starsChanged 4 months agoMITView on GitHub

Bundle CSS and JS assets in Laravel with Vite — configure vite.config.js, load bundles with the @vite Blade directive, run hot module reload in development, build versioned assets for production, and import CSS/JS entry points. Use when the user needs to compile, bundle, or serve frontend CSS and JavaScript assets in a Laravel 10+ application; the user wants live reloading or hot module replacement of assets during local Laravel development; the user needs to build minified, versioned (cache-busted) frontend assets for a production Laravel deploy. Keywords: vite, assets, bundling, hot-module-reload, laravel.

36 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use antfu-design, nitro and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • wltn7810-dotcomSkill

    antfu-design

    antfu-style design conventions, broadened. UnoCSS-first, class-based semantic tokens with dual light/dark for tooling and devtools UIs, plus design-read, anti-slop, and micro-interaction polish for landing pages and product surfaces. Use when building or refactoring any interface with UnoCSS.

    Also in 3 projects that use this

  • SentrySkill

    nitro

    Build and deploy universal JavaScript servers with Nitro v3. Use when working with nitro.config.ts, defineNitroConfig, defineHandler, defineConfig, server.ts entry, filesystem routing, route rules, useStorage, defineCachedHandler, useDatabase, definePlugin, runtime hooks, Vercel/Cloudflare deployment, or migrating from Nitro v2/nitropack.

    Also in 4 projects that use this

  • xfstudioSkill

    nodejs-backend-patterns

    Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.

    Also in 5 projects that use this

  • xenitV1Skill

    nodejs-best-practices

    Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.

    Also in 4 projects that use this

  • midudevSkill

    tailwind-css-patterns

    Provides comprehensive Tailwind CSS utility-first styling patterns including responsive design, layout utilities, flexbox, grid, spacing, typography, colors, and modern CSS best practices. Use when styling React/Vue/Svelte components, building responsive layouts, implementing design systems, or optimizing CSS workflow.

    Also in 3 projects that use this

  • xfstudioSkill

    typescript-advanced-types

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.

    Also in 5 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 31 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do not use this skill when the task is to maintain an existing webpack.mix.js Laravel Mix pipeline that cannot yet migrate.

    line 64
  2. Distinctive:

    Do not use this skill for API-only or server-rendered work that ships no CSS or JavaScript bundle.

    line 65
  3. Very specific:

    Run npm run dev while developing for hot module reload, and run npm run build in the deploy pipeline to produce the versioned production …

    line 81
  4. Very specific:

    Import stylesheets from a JS entry (for example import '../css/app.css' in resources/js/app.js) so Vite processes them, or list the CSS …

    line 88
  5. Distinctive:

    Not applicable — no I/O, auth, or untrusted input.

    line 116

“Common” is measured: kept by at least 6 in 10 of the 31 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- generated: do not edit — source: knowledge/atoms/laravel/vite/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->

Laravel Vite

When to use

  • The user needs to compile, bundle, or serve frontend CSS and JavaScript assets in a Laravel 10+ application.
  • The user wants live reloading or hot module replacement of assets during local Laravel development.
  • The user needs to build minified, versioned (cache-busted) frontend assets for a production Laravel deploy.

When NOT to use

  • Do not use this skill when the task is to maintain an existing webpack.mix.js Laravel Mix pipeline that cannot yet migrate; use the laravel/mix skill instead.
  • Do not use this skill for API-only or server-rendered work that ships no CSS or JavaScript bundle.

Core guidance

  • Run the dev server locally and build for production — Use npm run dev for local work so Vite serves assets with hot module reload; run npm run build in CI or on deploy to emit hashed files plus a manifest.
  • Load bundles through the @vite Blade directive — Reference entry points with the @vite([...]) Blade directive rather than hardcoding <script> or <link> tags. Pass the exact entry paths declared in vite.config.js, for example @vite(['resources/css/app.css', 'resources/js/app.js']).

Quick recipe

  1. In vite.config.js, register the laravel() plugin with an input array listing resources/css/app.css and resources/js/app.js and set refresh: true. (verify: npm run build emits files under public/build with a manifest.json)
  2. In the Blade layout <head>, add @vite(['resources/css/app.css', 'resources/js/app.js']) so both entry points are loaded through the directive. (verify: The rendered page includes the CSS and JS tags Vite generates)
  3. Run npm run dev while developing for hot module reload, and run npm run build in the deploy pipeline to produce the versioned production bundle. (verify: Local edits hot-reload; a production deploy serves hashed files with no dev server)

Best practices

  • List each CSS and JS entry point in the laravel() plugin input array inside vite.config.js; the @vite directive can only load paths declared there
  • Import stylesheets from a JS entry (for example import '../css/app.css' in resources/js/app.js) so Vite processes them, or list the CSS file directly in the plugin input array
  • Set refresh: true on the laravel() plugin in vite.config.js so edits to Blade views and routes trigger a full-page reload through the Vite dev server

Anti-patterns

Anti-patternWhy it failsDo instead
Committing built assets into version controlBuilt assets bloat the repo, cause constant merge conflicts on the manifest, and drift from source when someone forgets to rebuild.Gitignore public/build and generate it in CI or on deploy with npm run build.
Running the Vite dev server in productionThe dev server is unminified, unversioned, and binds to a local port, so it is slow, insecure, and unavailable to real users.Serve the static output of npm run build and let the web server deliver the hashed files under public/build.
Hand-writing script and link tags for bundlesManual tags cannot resolve the per-build manifest hash or switch to the dev server, so they break on rebuild and in development.Replace manual tags with @vite([...]), letting the directive resolve dev-server and manifest URLs automatically.

See references/anti-patterns.md.

Common mistakes

  1. Stale hot file makes production point at the dev server — A leftover public/hot file makes the @vite directive emit dev-server URLs in production, so assets fail to load. Fix: Delete public/hot on deploy (it is written by npm run dev and removed on shutdown) and add it to .gitignore.
  2. Deploying without running the production build — Deploying without npm run build leaves no manifest, so the @vite directive throws a "Vite manifest not found" error. Fix: Add npm ci && npm run build to the deploy pipeline and commit or ship the generated public/build output.
  3. Referencing public assets by literal build path — Hardcoding a hashed path like /build/assets/app-4f3a.js breaks on the next build because the hash changes. Fix: Always resolve asset URLs through the @vite directive (or Vite::asset() for static files) so the current manifest hash is used.

Version notes

  • Vite is the default bundler from Laravel 9.19+ — Vite ships as the default frontend bundler in Laravel 9.19+ and is the only bundler scaffolded in Laravel 10 and 11.

Security

  • Not applicable — no I/O, auth, or untrusted input.

Testing

  • Activation and decision behavior are verified in eval/scenarios/laravel/vite.yaml.

Additional resources

  • references/anti-patterns.md
  • references/core.md
  • references/examples.md
  • references/pitfalls.md
  • references/recipes.md
  • references/version-differences.md

Knowledge graph

Supersedes: laravel/mix

<!-- graph-fragment: graph/fragments/laravel/vite.yaml -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.