guihigashi / simple-vite-laravel

A Blade directive for Vite/React assets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Blade directive for Vite/React assets

Latest Stable Version Total Downloads

Installation

You can install the package via composer:

composer require guihigashi/simple-vite-laravel

Usage

Include @simple_vite in your app.blade.html to inject <script> and <link> tags based on the value of APP_ENV (production or else). If you use php artisan serve --host=0.0.0.0, also use yarn dev --host.

The defaults are based on this 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()],
}))

If you want to change defaults:

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

About

A Blade directive for Vite/React assets

License:Apache License 2.0


Languages

Language:PHP 100.0%