Open bee1194 opened 3 months ago
I got the same problem. Your fix works and doesn't :)
It does fix the problem in the module but if you have another npm run dev
on the root, you need to refresh it to get the update. I can't get both running at the same time.
... and my vite knowledge is too limited to understand what's going on.
I rather did this instead.
Created a new function.
Then copied the hot file to modules build directory and I don't need to refresh on modules page or non-modules pages.
if (! function_exists('panel_module_vite')) {
function panel_module_vite($module, $asset): Vite
{
//public_path('/build-tenant/hot')
return ViteFacade::useHotFile(public_path($module.'/hot'))
->useBuildDirectory($module)
->withEntryPoints([$asset]);
}
}
I see that in my case adding this line under plugins.laravel works:
hotFile: "../../storage/vite.hot",
It'll be somewhat like this for me, maybe this can be adjusted so that each module can have their own hotfile?
export default defineConfig({
...
plugins: [
laravel({
...
publicDirectory: "../../public",
hotFile: "../../storage/vite.hot"
...
})
]
...
})
Edit: Still need to adjust the module_vite helper though if you want to hot-run multiple module simultaneously
I have a module Admin. I want to load its own assets. These steps:
{{ module_vite('build-admin', 'resources/assets/sass/app.scss') }}
npm run dev
Vite manifest not found at: /var/www/html/public/build-admin/manifest.json
After debugging, I saw Module_vite is using "storage_path('vite.hot')", but my hot file is not in storage, It is in public. It will work when I replacestorage_path('vite.hot')
withViteFacade::hotFile()
function module_vite($module, $asset): Vite { return ViteFacade::useHotFile(ViteFacade::hotFile())->useBuildDirectory($module)->withEntryPoints([$asset]); }