Open shashankitsoft opened 9 months ago
I'm facing problem too, try to modify the Vite.php
in vendor
but no luck.
Can confirm this is an issue. I also modified Vite.php to test and it kinda worked if I hard coded the "public" directory in function manifestPath:
protected static function manifestPath($buildDirectory)
{
return 'public' . '/' . ltrim($buildDirectory, '/') . '/' . ltrim(static::$manifestFilename, '/');
}
However this only eliminates the leaf exception. The paths to the bundled assets are broken and the browser is trying to fetch from /assets/build/assets/ and that should just be /build/assets.
Again a simple hardcoding will deal with this:
protected static function assetPath($path, $secure = null)
{
return 'public' . '/' . ltrim($path, '/');
}
but in the end, it will need to pull these values from variables since the public directory isn't a hard requirement.
Hi, I've also tried to investigate this by doing these, and none of them worked:
./build
to ./public
(so /build/build
resolves to ./public/build
)./build
./app/build
./app/views/build
My best guess so far is this bug forces Leaf to find the desired /build/build
directory from the system's root directory.
[!NOTE] I have also discovered a similar bug when
assets('...')
behaves differently between dev and production: dev returns/assets/...
(the absolute path for loading asset URLs) while production returns/public/assets/...
. This is reported in leafsphp/mvc-core#14.
Did you were able to fix the problem?
I have got the same problem. In local env works fine if the command leaf serve
is executing. If you stop that command then I get the error Vite manifest not found at: /build/build/manifest.json
I think the issue in production is because there is a config missing to use cpanel or any other server. Because it is not posible to execute leaf serve.
I hope someone from LeafPHP team could help us.
I also still have found no way to resolve this or find any viable workaround.
A new version will be released to fix this issue soon. You can fix it for now in your codebase by adding this snippet to your public/index.php
file:
\Leaf\Vite::config('build', PublicPath('', false));
Скоро будет выпущена новая версия, исправляющая эту проблему. Вы можете исправить ее сейчас в своей кодовой базе, добавив этот фрагмент в свой
public/index.php
файл:\Leaf\Vite::config('build', PublicPath('', false));
We're very much looking forward to it!
Describe the bug Using leaf with MVC, created project using :
leaf create <project-name> --mvc
Windows 11, PHP 8.1, On command line, leaf --version = v2.11.1 As per composer json:As per package.json:
Now
leaf serve
works fine and site visible on http://localhost:5500/ Creating a build usingleaf view:build
generate successfully. But on running leaf serve give error Error: Vite manifest not found at: /build/build/manifest.jsonTo Reproduce
In default Leaf-MVC installation and added sass as above, create a css app\views\scss\test.css (having just one line css and an inner import of scss
test-inner1.scss also has just
div{color: green;}
Go to app\views\index.blade.php and include that css in head,
{{ vite('scss/test.css') }}
In .env set, APP_ENV=production (earlier it was 'local')
vite.config.js as below (just added css file name, rest as default):
export default defineConfig({ plugins: [ leaf({ input: ['app/views/js/app.js', 'app/views/css/app.css','app/views/scss/test.css'], refresh: true, }), ], });