Skip to content

Commit b9d26ba

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 0433b54 commit b9d26ba

File tree

5 files changed

+185
-3
lines changed

5 files changed

+185
-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: 6 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,11 @@ export default defineConfig({
1112
ssr: 'resources/js/ssr.tsx',
1213
refresh: true,
1314
}),
15+
run({
16+
name: 'ziggy',
17+
run: ['php', 'artisan', 'ziggy:generate', '--types-only'],
18+
pattern: 'routes/**/*.php',
19+
}),
1420
react(),
1521
tailwindcss(),
1622
],

0 commit comments

Comments
 (0)