Registry / web-framework / laravel-vite-plugin

laravel-vite-plugin

JSON →
library3.0.1jsnpmunverified

Laravel Vite Plugin integrates Vite with Laravel, providing hot module replacement and asset bundling tailored for Laravel projects. Version 3.0.1 requires Vite ^8.0.0 and Node ^20.19.0 or >=22.12.0. It ships with TypeScript definitions and follows Laravel's convention for Vite configuration. Unlike generic Vite plugins, it handles Blade asset referencing, hot file management, and server URL resolution for Laravel's backend-first workflow. Major version bumps align with Vite major releases; v3 introduced Vite 8 support. The plugin is actively maintained by the Laravel core team.

npm install laravel-vite-plugin
INSTALL
IMPORT
SIG · LARAVEL-VITE-PLUGI
L
laravel-vite-plugin
web-frameworkjavascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

laravel-vite-plugin
import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; export default defineConfig({ plugins: [laravel({ input: ['resources/js/app.js'] })] });
const laravel = require('laravel-vite-plugin');
ESM-only since v3; use import syntax. Default export is the plugin function.
refreshing
import { refreshing } from 'laravel-vite-plugin'; // Use in vite.config.js for custom refresh logic
const { refreshing } = require('laravel-vite-plugin');
Named export for Vite's handleHotUpdate; available as a named export.

Minimal Vite configuration for Laravel app with Vue support, enabling HMR and asset refresh.

// vite.config.js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import vue from '@vitejs/plugin-vue'; export default defineConfig({ plugins: [ laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true, }), vue(), ], });
Debug
Known issues
breakingv3 requires Vite 8 and Node >=20.19.0 or >=22.12.0; drop Vite 7 support.
fix
Upgrade Vite to ^8.0.0 and Node to a supported version (^20.19.0 or >=22.12.0).
affects: >=3.0.0
breakingv2 requires Vite 6 or 7 and Node 18+; drop Vite 5 support.
fix
Upgrade Vite to ^6.0.0 or ^7.0.0.
affects: >=2.0.0 <3.0.0
deprecatedUsing require() to import the plugin is deprecated; ESM-only since v3.
fix
Use import statement instead of require.
affects: >=3.0.0
gotchaHot file must be writable and may not auto-create parent directories in some setups; v2.0.1 added auto creation.
fix
Ensure the hotFile directory exists or upgrade to >=2.0.1.
affects: <2.0.1
gotchaDefault CORS origins added in v1.2.0; missing CORS headers can cause HMR issues.
fix
Add CORS origins manually or upgrade to >=1.2.0.
affects: <1.2.0
Errors
Common errors & fixes
laravel-vite-plugin tried to access a property of undefined (reading 'env')
Using an unsupported Vite version (e.g., Vite 5 with plugin v3).
fix
Ensure Vite version matches plugin peer dependency (^8.0.0 for v3).
Cannot find module 'laravel-vite-plugin'
Package not installed or using require() in ESM-only context.
fix
Install the package: npm install laravel-vite-plugin --save-dev. Use import instead of require.
TypeError: laravel is not a function
Incorrect import syntax; may be using default import incorrectly.
fix
Use import laravel from 'laravel-vite-plugin' (default export).
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
viterequiredpeer dependency for Vite 8 support
Agent activity
4 hits · last 30 days
node
4
Resources
laravel-vite-plugin — npm install laravel-vite-plugin · libregistry