Skip to content

Instantly share code, notes, and snippets.

View innocenzi's full-sized avatar
🦋

Enzo Innocenzi innocenzi

🦋
View GitHub Profile
@innocenzi
innocenzi / some-page.vue
Last active June 24, 2022 13:14
Dealing with cached visits with Inertia
<script setup lang="ts">
import { useBackForward } from '@/scripts/use-back-forward'
const { reloadOnBackForward } = useBackForward()
// When the page component is loaded, if it's a visit made with the "back" or "forward"
// browser functionality, the page will reload. You can optionally pass options to Inertia.
reloadOnBackForward({
only: ['quotations'],
})
@innocenzi
innocenzi / README.md
Last active May 12, 2022 11:35
Karabiner elements

command and option should be inverted as a simple modification in Karabiner

<?php
namespace Tests;
/** @mixin TestCase */
trait BenchmarksTests
{
protected static array $tests = [];
protected function setUpBenchmark(): void
@innocenzi
innocenzi / package.json
Last active April 1, 2023 13:01
Laravel + Vite + Inertia SSR
{
"scripts": {
"dev": "npx esno server.ts",
"build": "vite build",
"build:ssr": "vite build --ssr",
"build:all": "npm run build && npm run build:ssr"
}
}
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
/**
* Generates a JSON file with all translations.
import { Plugin } from 'vite'
const PLUGIN_NAME = 'vite:inertia:layout'
const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"](?:(?:(\w+):)?(\w+))['"] *)?>/
export default (layouts: string = '@/views/layouts/'): Plugin => ({
name: PLUGIN_NAME,
transform: (code: string) => {
if (!TEMPLATE_LAYOUT_REGEX.test(code)) {
return
@innocenzi
innocenzi / README.md
Last active November 21, 2022 13:41
Vite + Inertia SSR

package.json:

{
  "scripts": {
    "dev": "vite",
    "dev:server": "node public/build/server/server.js",
    "build": "vite build",
    "build:server": "vite build --outDir ./public/build/server --ssr ./resources/scripts/inertia/server.ts"
  }
}
@innocenzi
innocenzi / GenerateI18n.php
Last active July 18, 2022 18:18
VITL translations
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
/**
* Generates a JSON file with all translations.
import path from 'path'
import vue from '@vitejs/plugin-vue'
import icons from 'vite-plugin-svg-icons'
import inspect from 'vite-plugin-inspect'
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'
import createDebugger from 'debug'
import { defineConfig } from 'laravel-vite'
export default defineConfig()
@innocenzi
innocenzi / vite.config.ts
Created August 4, 2021 12:45
vite-hmr-error
import { defineConfig, Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
// TODO: should be taken from environment
const certificates = {
key: 'D:\\Programmes\\Laragon\\etc\\ssl\\laragon.key',
crt: 'D:\\Programmes\\Laragon\\etc\\ssl\\laragon.crt',
}
export default defineConfig(({ command }) => ({