104 lines
2.8 KiB
JavaScript
104 lines
2.8 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, realpathSync, 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 = [];
|
|
const physicalFiles = new Set();
|
|
|
|
for (const moduleName of readdirSync(modulesPath)) {
|
|
const modulePath = join(modulesPath, moduleName);
|
|
|
|
if (!statSync(modulePath).isDirectory()) {
|
|
continue;
|
|
}
|
|
|
|
for (const resourcesDirectory of ['Resources', 'resources']) {
|
|
for (const entry of ['assets/css/app.css', 'assets/js/app.js']) {
|
|
const candidate = join(modulePath, resourcesDirectory, entry);
|
|
|
|
if (!existsSync(candidate)) {
|
|
continue;
|
|
}
|
|
|
|
const physicalPath = realpathSync(candidate);
|
|
|
|
if (physicalFiles.has(physicalPath)) {
|
|
continue;
|
|
}
|
|
|
|
physicalFiles.add(physicalPath);
|
|
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) {
|
|
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/*/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/**',
|
|
],
|
|
},
|
|
},
|
|
});
|