samuelmwangiw / laravel-vite
A tiny package that adds @vite_assets blade directive and loads Vite assets
Installs: 1 807
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ^8.0
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- guzzlehttp/guzzle: ^7.2
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- pestphp/pest-plugin-mock: ^1.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
README
Since version 9.19 Laravel ships with first-party support for Vite. This package is therefore not required anymore
A tiny package that swaps out Webpack (Laravel-Mix) for Vite in you Laravel project.
This improves the developer experience by using the blazing fast Vite HMR instead of webpack compilation offered by Webpack through Laravel Mix
Installation
The easiest way to get started is on a new Laravel project.
- Create a new project and run the following command:
laravel new awesome-project
- Setup Jetstream with Inertia
cd awesome-project
composer require laravel/jetstream
php artisan jetstream:install inertia
- or Breeze with Vue
cd awesome-project
composer require laravel/breeze --dev
php artisan breeze:install vue
- Then install this package via composer:
composer require --dev samuelmwangiw/laravel-vite
- Run
vite:install
command to setup vite
php artisan vite:install
- Run
npm install
to install the dependencies andnpm run dev
to start the development server - (Optional) Since the package publishes all assets to your
App
namespace during setup, it's safe to remove the package from your dependencies
composer remove --dev samuelmwangiw/laravel-vite
- Build your amazing project
Laravel Sail
If running Sail for local development, this package provides a handy sail
npm script that runs vite --host
under the hood as vite
is only accessible via the loopback interface (127.0.0.1) by default and would therefore not be accessible in the docker container.
npm run sail
You may optionally publish the config if you connect to the docker host running vite via a custom address/port different from http://host.docker.internal:3000
php artisan vendor:publish --provider="SamuelMwangiW\Vite\ViteServiceProvider"
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Samuel Mwangi
- Sebastian De Deyne whose blog inspired this package
- All Contributors
License
The MIT License (MIT). Please see License File for more information.