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 } from 'node:fs'; import { join, relative } from 'node:path'; const projectRoot = process.cwd(); /** * Discover module CSS/JS entry points. * * Supported module layouts: * * Modules/Foo/Resources/assets/css/app.css * Modules/Foo/Resources/assets/js/app.js * * and the lower-case equivalent: * * Modules/Foo/resources/assets/css/app.css * Modules/Foo/resources/assets/js/app.js */ function discoverModuleInputs() { const modulesPath = join(projectRoot, 'Modules'); if (!existsSync(modulesPath)) { return []; } const inputs = []; for (const moduleName of readdirSync(modulesPath)) { const modulePath = join(modulesPath, moduleName); const candidates = [ join(modulePath, 'Resources/assets/css/app.css'), join(modulePath, 'Resources/assets/js/app.js'), join(modulePath, 'resources/assets/css/app.css'), join(modulePath, 'resources/assets/js/app.js'), ]; for (const candidate of candidates) { 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}`); } } else { console.log('[Vite] No module asset entry points discovered.'); } 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/*/resources/views/**/*.blade.php', 'Modules/*/resources/assets/**/*', 'Modules/**/*.php', ], fonts: [ bunny('Instrument Sans', { weights: [400, 500, 600], }), ], }), tailwindcss(), ], server: { cors: true, watch: { ignored: [ '**/storage/framework/views/**', '**/Modules/*/node_modules/**', ], }, }, });