Skip to content

Instantly share code, notes, and snippets.

@sawirricardo
Created July 13, 2022 00:58
Show Gist options
  • Save sawirricardo/c057389ca585de0f87cdadacc3955f3a to your computer and use it in GitHub Desktop.
Save sawirricardo/c057389ca585de0f87cdadacc3955f3a to your computer and use it in GitHub Desktop.
Filament Vite
@import "../../vendor/filament/filament/resources/css/app.css";
@tailwind base;
@tailwind components;
@tailwind utilities;
<?php
namespace App\Providers;
use Filament\Facades\Filament;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Filament::serving(function () {
Filament::registerRenderHook(
'body.start',
fn (): string => Blade::render('@vite(["resources/js/app.js", "resources/css/app.css"])'),
);
});
}
}
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import fs from "fs";
import { homedir } from "os";
import { resolve } from "path";
let host = "hivivaldy.test";
export default defineConfig({
plugins: [
laravel({
input: ["resources/css/app.css", "resources/js/app.js"],
refresh: true,
}),
],
server: detectServerConfig(host),
});
function detectServerConfig(host) {
let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`);
let certificatePath = resolve(
homedir(),
`.config/valet/Certificates/${host}.crt`
);
if (!fs.existsSync(keyPath)) {
return {};
}
if (!fs.existsSync(certificatePath)) {
return {};
}
return {
hmr: { host },
host,
https: {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certificatePath),
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment