47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
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();
|
|
|
|
const backendCssEntry = existsSync(
|
|
join(projectRoot, 'resources/themes/backend/assets/css/app.css')
|
|
)
|
|
? 'resources/themes/backend/assets/css/app.css'
|
|
: 'resources/themes/backend/assets/css/helpdesk.css';
|
|
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;
|
|
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();
|
|
export default defineConfig({
|
|
plugins:[
|
|
laravel({
|
|
input:[
|
|
backendCssEntry,
|
|
'resources/themes/backend/assets/css/auth.css',
|
|
'resources/themes/backend/assets/js/passkeys.js',
|
|
'resources/themes/backend/assets/js/layout.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/**']}},
|
|
});
|