nongbit / codeigniter-vite
Integrate Vite to CodeIgniter 4
Installs: 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nongbit/codeigniter-vite
README
Integrate Vite to CodeIgniter 4.
Setup
Download package using composer.
composer require nongbit/codeigniter-vite
Run command to initiate vite.
php spark vite:init
Create and open APPPATH/Config/Vite.php.
<?php namespace Config; use CodeIgniter\Config\BaseConfig; class Vite extends BaseConfig { public array $entryPoints = [ '' => 'app/Views/assets/js/app.js', ]; }
Usage
Inside your view, call vite_url().
If the vite server is active then vite_url() will produce code like the following.
<script type="module" src="http://localhost:5173/app/Views/assets/js/app.js"></script>
If manifest.json is found then vite_url() will read the file and generate the appropriate html code, something like this:
<link rel="stylesheet" href="http://localhost/assets/app.css"> <script type="module" src="http://localhost/assets/app.js">