Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brandcom/cakephp-vite

ViteHelper plugin for CakePHP and Vite JS
https://github.com/brandcom/cakephp-vite

bundler cakephp devserver es-modules hot-module-replacement legacy-support php vite vitejs

Last synced: 7 days ago
JSON representation

ViteHelper plugin for CakePHP and Vite JS

Awesome Lists containing this project

README

        

# ViteHelper plugin for CakePHP 5

The plugin provides a Helper Class for CakePHP to facilitate the use of [Vite JS](https://vitejs.dev/).

When running the Vite dev server, the Helper provides the right script tags for hot module replacement and page
reloading.

In production mode, the Helper loads the bundled files. `@vitejs/plugin-legacy` is supported, which will
insert `nomodule`-tags for older browsers, e.g. older iOS devices, which do not support js modules.

> This readme is for **version 1.x.** If you are migrating from 0.x and something is unclear, read the Migration guide
> under `/docs`. Feel free to open an issue if you run into problems.

## Installation

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

### CakePHP Version Map

| CakePHP version | Plugin Version | Branch | min. PHP Version |
|-----------------|----------------|--------|------------------|
| ^3.10 | / | cake3 | ^7.4 |
| ^4.2 | 0.x | master | ^7.4 |
| ^4.2 | 1.x | master | ^8.0 |
| ^5.0 | 2.x | cake5 | ^8.1 |

The recommended way to install the plugin is:

```shell
composer require passchn/cakephp-vite
```

Load the plugin in your Application.php:

```shell
bin/cake plugin load ViteHelper
```

Load the Helper in your AppView.php:

```php
$this->loadHelper('ViteHelper.ViteScripts');
```

## Usage

In your php-layout, include this in your html head:

```php
= $this->fetch('css') ?>
```

Just before the closing `