@defstudio/vite-livewire-plugin

中文文档
3.0.7发布于 2026/04/27MITTypeScriptESM + CJS构建来源已验证近 30 天下载 3.7万

Livewire plugin for Vite

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Usage & Documentation
  4. Changelog
  5. Contributing
  6. Security Vulnerabilities
  7. Credits
  8. License
  9. Demo

Vite Livewire Plugin

Total Downloads Latest Stable Version License Twitter Follow

Vite has become Laravel's default frontend build tool.

This plugin (made by def:studio) configures Vite for use with a Livewire setup, allowing components hot reload without losing their state when their blade or class files change.

Demo video available below in this page

Installation

Prior to install, read carefully our documentation at https://docs.defstudio.it/vite-livewire-plugin

npm install --save-dev @defstudio/vite-livewire-plugin

Usage

Livewire hot reload can be enabled by adding the livewire() plugin to the vite.config.js file:

import {defineConfig} from 'vite';
import laravel from 'laravel-vite-plugin';

import livewire from '@defstudio/vite-livewire-plugin'; // <-- import

export default defineConfig({
    //...
    
    plugins: [
        laravel([
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
            ],
            refresh: false, // <-- disables laravel autorefresh, to avoid conflicts
        ]),
        
        livewire({  // <-- add livewire plugin
            refresh: ['resources/css/app.css'],  // <-- will refresh css (tailwind ) as well
        }),
    ],
});

and add the livewire hot reload manager in your app.js file:

//..

import {livewire_hot_reload} from 'virtual:livewire-hot-reload'

livewire_hot_reload();

After the Vite server is started, you should see the init message on your browser console:

[vite] connecting...
[vite] livewire hot reload ready.
[vite] connected.

From now on, when a .blade.php or Livewire .php class is updated, the hot reload will trigger a refresh for all Livewire components in page (and the app.css file as well):

[vite] css hot updated: /resources/css/app.css
[vite] livewire hot updated.

Warning This Vite plugin, as Livewire needs to persist in page, is not fully compatible with other plugins that full refresh the page when a .blade.php file changes (i.e. laravel/vite-plugin with refresh option active) in order to make them work together, blade files in **/livewire/** should be excluded from blade hot reload. For Laravel Vite plugin, this config would solve the issue:

// vite.config.js
export default defineConfig({
//...
    plugins: [
        //...
    
        laravel({
            // ...
            refresh: false,
        })
    ],
});

Usage & Documentation

An extensive documentation is available at

https://docs.defstudio.it/vite-livewire-plugin

Changelog

Please see CHANGELOG for more information on what has changed recently. Follow Us on Twitter for more updates about this package.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Demo

https://user-images.githubusercontent.com/8792274/176996785-d4e21ee5-b9f3-4e91-bf3a-4bbc0e87a148.mp4

版本与发布记录

@defstudio/vite-livewire-plugin 共发布 61 个版本,首次发布于 2022/07/01;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.0.7latest2026/04/276 个月前
3.0.22025/07/141.3 年前
3.0.02025/07/071.3 年前
2.0.62024/12/031.9 年前
2.0.52024/04/262 年前
2.0.42024/04/182 年前

关于 @defstudio/vite-livewire-plugin 的常见问题

@defstudio/vite-livewire-plugin 是什么?

Livewire plugin for Vite

如何安装 @defstudio/vite-livewire-plugin?

在项目目录运行 npm install @defstudio/vite-livewire-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vite(^8.0.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@defstudio/vite-livewire-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@defstudio/vite-livewire-plugin 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@defstudio/vite-livewire-plugin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.19.0 || >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@defstudio/vite-livewire-plugin 可以商用吗?

@defstudio/vite-livewire-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@defstudio/vite-livewire-plugin 的下载量有多少?

根据 npm 官方下载统计,@defstudio/vite-livewire-plugin 在 2026/10/12 – 2026/11/10 这 30 天内被下载 36,958 次,日均约 1,232 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@defstudio/vite-livewire-plugin 还在维护吗?

最新版本 3.0.7 发布于 2026/04/27(6 个月前);至今共发布 61 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/07/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。