import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import { bunny } from 'laravel-vite-plugin/fonts'; import tailwindcss from '@tailwindcss/vite'; import { existsSync, readdirSync, statSync } from 'node:fs'; import { join, relative } from 'node:path'; const projectRoot = process.cwd(); function discoverModuleInputs() { const modulesPath = join(projectRoot, 'Modules'); if (!existsSync(modulesPath)) { return []; } const inputs = []; for (const moduleName of readdirSync(modulesPath)) { const modulePath = join(modulesPath, moduleName); if (!statSync(modulePath).isDirectory()) { continue; } // Canonical Laravel Modules asset paths only. for (const entry of [ 'Resources/assets/css/app.css', 'Resources/assets/js/app.js', ]) { const candidate = join(modulePath, entry); if (existsSync(candidate)) { inputs.push(relative(projectRoot, candidate)); } } } return inputs; } const moduleInputs = discoverModuleInputs(); console.log('[Vite] Backend theme inputs:'); console.log(' resources/themes/backend/assets/css/app.css'); console.log(' resources/themes/backend/assets/js/passkeys.js'); if (moduleInputs.length > 0) { console.log('[Vite] Module inputs:'); for (const input of moduleInputs) { console.log(` ${input}`); } } export default defineConfig({ plugins: [ laravel({ input: [ 'resources/themes/backend/assets/css/app.css', 'resources/themes/backend/assets/js/passkeys.js', ...moduleInputs, ], refresh: [ 'resources/themes/backend/views/**/*.blade.php', 'resources/themes/backend/assets/**/*', 'Modules/*/Resources/views/**/*.blade.php', 'Modules/*/Resources/assets/**/*', 'Modules/**/*.php', ], fonts: [ bunny('Instrument Sans', { weights: [400, 500, 600], optimizedFallbacks: false, }), ], }), tailwindcss(), ], server: { cors: true, watch: { ignored: [ '**/storage/framework/views/**', '**/Modules/*/node_modules/**', ], }, }, });