PHP code example of arnoson / kirby-vite

1. Go to this page and download the library: Download arnoson/kirby-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/ */

    

arnoson / kirby-vite example snippets


<html>
  <head>
    <?= vite()->css('index.css') 

 <link rel="preload" href="<?= vite()->file('my-font.woff2') 

vite()->js('templates/' . $page->template() . '.js', try: true);
vite()->css('templates/' . $page->template() . '.css', try: true);
vite()->file('maybe.woff2', try: true);

vite()->js('templates/{{ page.template }}.js');
vite()->css('templates/{{ page.template }}.css');

<!-- your template -->
<?= vite()->js('index.js') 

 return [
  'ready' => fn() => [
    'panel' => [
      // If you have a `panel.js` file, that imports the `panel.css` file:
      'css' => vite()->panelCss('panel.js'),
      'js' => vite()->panelJs('panel.js'),

      // If you only have a `panel.css` without a js file you must still use
      // `vite()->panelJs()`, as this injects the vite client in development.
      'css' => vite()->panelCss('panel.css'),
      'js' => vite()->panelJs(),
    ],
  ],
];