-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x] Mix to Vite migration #1391
Conversation
Migrated from laravel mix to vite following official migration guide: https://laravel.com/docs/10.x/vite vite
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Hmm, I'm keep getting the following error after upgrading:
I've run Horizon, etc. work fine, but Telescope is broken. |
@esurov Telescope actually doesn't even work in Laravel applications anymore when the application is running |
This reverts commit 46b85cd.
@esurov the problem is the "hot file" path... It need to be set in place or before of the The problem is because the default hot path is relative to the main application not telescope, so when we run Example how to fix: // .../telescope/resources/view/layout.blade.php
// Maybe it's better to set it in the TelescopeServiceProvider but this works for test purposes
{{ Vite::useHotFile('public/hot') }}
@vite('resources/sass/' . $cssFile, '/vendor/telescope/build') |
If we revisit this, we should consider: laravel/framework#48964 |
As a person who extensively uses Vite in my own packages, I already have solutions for this problem. Define hot file path in templatelayout.blade.php {{ Vite::useHotFile('vendor/my-package/hot')
->useBuildDirectory('vendor/my-package/build')
->withEntryPoints(['resources/js/app.js', "resources/js/pages/{$page['component']}.vue"]) }} The problem with this solution is, the Use macro or mixinMyPackageServiceProvider.php public function boot()
{
Vite::mixin(new Support\ViteAliasMixin);
} ViteAliasMixin.php <?php
namespace MyVendor\MyPackage\Support;
use Illuminate\Foundation\Vite;
class ViteAliasMixin
{
protected function myPackageEntryPoint(): \Closure
{
return fn (array $page) => $this
->useHotFile('vendor/my-package/hot')
->useBuildDirectory('vendor/my-package/build')
->withEntryPoints(['resources/js/app.js', "resources/js/pages/{$page['component']}.vue"]);
}
} layout.blade.php {{ Vite::myPackageEntryPoint($page) }} I use this solution in my packages, but it has same flaws as the previous one. Implement some kind of Vite config manager and configure its instance in package's service providerI already had PR for this, but unfortunately it was closed, so I implemented this functionality as a package. MyPackageServiceProvider.php public function boot()
{
Vite::app('my-package')
->useHotFile('vendor/my-package/hot')
->useBuildDirectory('vendor/my-package/build')
->withEntryPoints(['resources/js/app.js']);
} layout.blade.php @viteApp('my-package') |
Migrated from laravel mix to vite following official migration guide: https://laravel.com/docs/10.x/vite
vite