Skip to content

Commit a7e7a81

Browse files
committed
Get Intellisense with Ziggy's route helper out of the box
- Ignore Ziggy generated files - Watch route changes in vite config with `vite-plugin-run`
1 parent 2738d72 commit a7e7a81

File tree

5 files changed

+187
-3
lines changed

5 files changed

+187
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ yarn-error.log
2222
/.nova
2323
/.vscode
2424
/.zed
25+
resources/js/ziggy.*

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
resources/js/components/ui/*
2-
resources/js/ziggy.js
2+
resources/js/ziggy.*
33
resources/views/mail/*

package-lock.json

Lines changed: 175 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"prettier": "^3.4.2",
2121
"prettier-plugin-organize-imports": "^4.1.0",
2222
"prettier-plugin-tailwindcss": "^0.6.11",
23-
"typescript-eslint": "^8.23.0"
23+
"typescript-eslint": "^8.23.0",
24+
"vite-plugin-run": "^0.6.1"
2425
},
2526
"dependencies": {
2627
"@headlessui/react": "^2.2.0",

vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react';
33
import laravel from 'laravel-vite-plugin';
44
import { resolve } from 'node:path';
55
import { defineConfig } from 'vite';
6+
import { run } from 'vite-plugin-run';
67

78
export default defineConfig({
89
plugins: [
@@ -11,6 +12,13 @@ export default defineConfig({
1112
ssr: 'resources/js/ssr.tsx',
1213
refresh: true,
1314
}),
15+
run([
16+
{
17+
name: 'ziggy',
18+
run: ['php', 'artisan', 'ziggy:generate', '--types-only'],
19+
pattern: ['routes/**/*.php'],
20+
},
21+
]),
1422
react(),
1523
tailwindcss(),
1624
],

0 commit comments

Comments
 (0)