PHP code example of vernok / vite-plugin

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

    

vernok / vite-plugin example snippets


$this->addJs('vite:resources/formwidgets/color-picker/entrypoint.ts');

$this->addJs('vite:resources/modules/checkout/entrypoint.ts');

$this->addJs('vite:resources/modules/admin/entrypoint.ts');

$this->addJs('vite:resources/modules/admin/entrypoint.ts');

$this->addCss('vite:resources/scss/admin.scss');

$this->addJs('vite:theme:resources/entrypoint.ts');
$this->addJs('vite:plugin:Acme.Blog:resources/modules/blog/entrypoint.ts');

vite_scripts(['resources/entrypoint.ts']);
vite_styles(['resources/entrypoint.ts']);
vite_asset('resources/images/hero.webp');

$assets = vite_assets(['resources/modules/admin/entrypoint.ts'], 'plugin', 'Vendor.Plugin');
foreach ($assets['js'] as $js) {
    $controller->addJs($js['url'], array_filter(['type' => $js['type'] ?? null]));
}
foreach ($assets['css'] as $css) {
    $controller->addCss($css['url']);
}

use Vernok\Vite\Classes\Traits\HasViteAssets;

class BlogList extends ComponentBase
{
    use HasViteAssets;

    public function onRun(): void
    {
        $this->addViteAssets(['resources/modules/blog/entrypoint.ts']);
        // Or explicit scope:
        // $this->addViteAssets([...], 'plugin', 'Acme.Blog');
    }
}

Event::listen('cms.page.init', function ($controller) {
    $controller->addJs('vite:resources/modules/analytics/entrypoint.ts');
});
bash
composer october:up
bash
php artisan plugin:install Vernok.Vite
bash
php artisan plugin:test Vernok.Vite