arbims/vite-plugin

为 CakePHP 定制的 VitePlugin 插件

安装次数: 157

依赖关系: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:cakephp-plugin

v1.0.3 2024-05-28 08:14 UTC

This package is auto-updated.

Last update: 2024-09-28 09:15:13 UTC


README

安装

您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。

安装 composer 包的推荐方式是

composer require arbims/vite-plugin

在 Application.php 中加载插件

bin/cake plugin load VitePlugin

在 AppView.php 中加载 Helper

$this->loadHelper('VitePlugin.Vite');

在 /config/bootstrap.php 中添加 Vite 环境配置

Configure::write('IS_DEV', true);

用法

运行以下命令

如果您想使用 vue 替换 react 或 preact

bin/cake vite_plugin react

在您的 php-layout 中,在 html head 中包含以下内容

<?= $this->Vite->assets('js/main.jsx', \Cake\Core\Configure::read('IS_DEV'), 'react') ?>

如果您想使用 vue

<?= $this->Vite->assets('js/main.js', \Cake\Core\Configure::read('IS_DEV')) ?>

然后运行

npm install
npm install -D sass
npm run dev

如果我们处于生产环境,需要将 IS_DEV 变量改为 false。

Configure::write('IS_DEV', false);

然后运行

npm run build