horizom / vite
Horizom 路由包。
5.0.0
2024-04-11 22:20 UTC
Requires
- php: ^8.0
This package is not auto-updated.
Last update: 2024-09-27 23:22:41 UTC
README
描述
Vite 是一款现代前端构建工具,提供极快的开发环境,并为生产环境打包您的代码。
此插件配置 Vite 以与 PHP 后端服务器一起使用。
使用
use Horizom\Vite\Vite; // Your entry point $entry = 'resources/js/app.js'; $config = [ /** * The build directory (default: 'public/dist') */ 'outputDir' => 'public/dist', /** * Force development mode (default: false) */ 'forceDev' => false, /** * The host (default: 'https://:5173') */ 'host' => 'https://:5173', /** * The manifest file (default: '.vite/manifest.json') */ 'manifest' => '.vite/manifest.json', /** * The base path (default: '') */ 'basePath' => '', ]; $plugin = new Vite($config); // Render the html tags $plugin->render($entry);
并在 vite.config.js
文件中设置您的 vite 配置
import { defineConfig, splitVendorChunkPlugin } from "vite"; import path from "node:path"; import vue from "@vitejs/plugin-vue"; import liveReload from "vite-plugin-live-reload"; export default defineConfig({ plugins: [ vue(), liveReload([ __dirname + "/resources/views/**/*.php", __dirname + "/app/*.php", ]), splitVendorChunkPlugin(), ], publicDir: path.resolve(__dirname, "storage/assets"), base: process.env.APP_ENV === "development" ? "/" : "/dist/", build: { outDir: "./public/dist", emptyOutDir: true, manifest: true, rollupOptions: { input: path.resolve(__dirname, "resources/js/app.js"), }, }, });
许可协议
Laravel Vite 插件是开源软件,根据MIT 许可协议授权。