PHP code example of lukaskleinschmidt / kirby-laravel-vite

1. Go to this page and download the library: Download lukaskleinschmidt/kirby-laravel-vite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lukaskleinschmidt / kirby-laravel-vite example snippets


<!doctype html>
<head>
  <?= vite(['assets/css/app.css', 'assets/js/app.js']) 

<!doctype html>
<head>
  <?= vite([
    // Using the Kirby Query Language
    'assets/css/templates/{{ page.template }}.css',
    'assets/js/templates/{{ page.template }}.js',

    // Equivalent to this
    '@assets/css/templates/' . $page->template() . '.css',
    '@assets/js/templates/' . $page->template() . '.js',
  ]) 

return [
    'ready' => fn () => [
        'panel' => [
            'css' => vite('assets/css/panel.css'),
            'js'  => vite([
                'assets/js/feature.js',
                'assets/js/panel.js',
            ]),
        ],
    ]
];

<?= vite()->reactRefresh() 

<img src="<?= vite()->asset('assets/images/logo.png') 

return [
    'lukaskleinschmidt.laravel-vite' => [
        'scriptTagAttributes' => [
            'data-turbo-track' => 'reload', // Specify a value for the attribute...
            'async'            => true,     // Specify an attribute without a value...
            'integrity'        => false,    // Exclude an attribute that would otherwise be 

return [
    'lukaskleinschmidt.laravel-vite' => [
        'scriptTagAttributes' => fn (string $src, string $url, array $chunk, array $manifest) => [
            'data-turbo-track' => $src === 'assets/js/app.js' ? 'reload' : false,
        ],
        'styleTagAttributes' => fn (string $src, string $url, array $chunk, array $manifest) => [
            'data-turbo-track' => $chunk && $chunk['isEntry'] ? 'reload' : false,
        ],
    ],
];

return [
    'lukaskleinschmidt.laravel-vite' => [
        'hotFile'        => fn () => kirby()->root('storage') . '/vite.hot',
        'buildDirectory' => 'bundle',
        'manifest'       => 'assets.json',
    ],
];

use LukasKleinschmidt\Vite;

return [
    'ready' => function () {
        Vite::instance()
            ->useHotFile(kirby()->root('storage') . '/vite.hot')
            ->useBuildDirectory('bundle')
            ->useManifest('assets.json');
    },
];

<!doctype html>
<head>
  <?=
    vite()->useHotFile($kirby->root('storage') . '/vite.hot')
          ->useBuildDirectory('bundle')
          ->useManifest('assets.json')
          ->withEntries(['assets/js/app.js'])