gymmed / bagisto-vite-parser
Neat way to locate documents build with vite laravel library in bagisto project. Helps to find manifest.json while using config/bagisto-vite.
This package is auto-updated.
Last update: 2025-03-29 01:09:17 UTC
README
Bagisto Vite Parser

Neat way to locate documents build with vite laravel library in bagisto project. Helps to find manifest.json while using config/bagisto-vite.
Installation
You can install the package via composer:
composer require gymmed/bagisto-vite-parser
Use Case
Dompdf and its laravel wrapper, laravel-dompdf, only support direct CSS or external CSS file links. However, these CSS files require real relative paths, while Vite in Laravel uses hashed filenames to avoid name collisions. This library provides an easy way to retrieve the correct CSS paths from config/bagisto-vite, specifically designed for Bagisto, not for general Laravel usage.
Usage
In your config/bagisto-vite.php, add a new entry for your package under the viters section. Example:
return [ 'viters' => [ ... 'myNamespace' => [ 'hot_file' => 'myNamespace-default-vite.hot', 'build_directory' => 'themes/myNamespace/default/build', 'package_assets_directory' => 'src/Resources/assets', ], ], ];
This should correspond to the laravel plugin configuration in your package's vite.config.js. Example:
plugins: [ ... vue(), laravel({ hotFile: "../../../public/myNamespace-default-vite.hot", publicDirectory: "../../../public", buildDirectory: "themes/myNamespace/default/build", input: [ "src/Resources/assets/css/app.css", "src/Resources/assets/js/app.js", ], refresh: true, }), ],
To get documents real paths we write:
use GymMed\BagistoViteParser; //provide full path $viteDocumentsPaths = BagistoViteParser::getDocumentsPaths( [ 'src/Resources/assets/css/app.css', 'src/Resources/assets/js/app.js' ], 'myNamespace' );
returned results:
array:2 [▼ 0 => "...\bagisto\public\themes/myNamespace/befault/build/assets/app-2bf84331.css" 1 => "...\bagisto\public\themes/myNamespace/default/build/assets/app-c35c0f3a.js" ]
and you can get single document path:
use GymMed\BagistoViteParser; //provide full path $viteDocumentsPaths = BagistoViteParser::getDocumentPath( 'src/Resources/assets/css/app.css', 'myNamespace' );