guihigashi/simple-vite-laravel

用于 Vite/React 资产的 Blade 指令

1.0.4 2022-04-09 00:24 UTC

This package is auto-updated.

Last update: 2024-09-09 05:22:37 UTC


README

Latest Stable Version Total Downloads

安装

您可以通过 composer 安装此包

composer require guihigashi/simple-vite-laravel

使用方法

在您的 app.blade.html 中包含 @simple_vite 以根据 APP_ENV 的值(production 或其他)注入 <script><link> 标签。如果您使用 php artisan serve --host=0.0.0.0,也请使用 yarn dev --host

默认值基于此 vite.config.ts

import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"

export default defineConfig(({ command }) => ({
    base: command === "serve" ? "" : "/dist/",
    publicDir: false,
    build: {
        manifest: true,
        outDir: "public/dist",
        polyfillModulePreload: false,
        rollupOptions: {
            input: "resources/scripts/main.tsx",
        },
    },
    plugins: [react()],
}))

如果您想更改默认值

php artisan vendor:publish --tag=simple-vite