Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m46s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m49s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m7s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m51s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m12s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m11s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m33s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
88 lines
3.3 KiB
JavaScript
88 lines
3.3 KiB
JavaScript
/**
|
||
* Vite-Voreinstellung für Inhaus-Plugins (Plugin-SDK).
|
||
*
|
||
* // vite.config.js im Plugin
|
||
* import { defineConfig } from 'vite';
|
||
* import { inhausPlugin } from './inhaus-sdk/vite.js';
|
||
* export default defineConfig(inhausPlugin());
|
||
*
|
||
* Baut jede Vue-Datei unter resources/js/{pages,widgets,blocks,profile,profile-panels,editorial}/
|
||
* als eigenes ES-Modul nach dist/ und schreibt dist/inhaus.json. Vue, Inertia und @inhaus/ui
|
||
* bleiben extern – das Portal stellt sie per Import Map bereit.
|
||
*/
|
||
import { existsSync, globSync } from 'node:fs';
|
||
import { resolve } from 'node:path';
|
||
import vue from '@vitejs/plugin-vue';
|
||
import tailwindcss from '@tailwindcss/vite';
|
||
|
||
export const KINDS = ['pages', 'widgets', 'blocks', 'profile', 'profile-panels', 'editorial'];
|
||
export const EXTERNAL = ['vue', '@inertiajs/vue3', '@inhaus/ui'];
|
||
|
||
export function inhausPlugin({ root = process.cwd() } = {}) {
|
||
const input = {};
|
||
|
||
for (const kind of KINDS) {
|
||
for (const file of globSync(`resources/js/${kind}/**/*.vue`, { cwd: root })) {
|
||
const name = file.replace(`resources/js/${kind}/`, '').replace(/\.vue$/, '');
|
||
input[`${kind}/${name}`] = resolve(root, file);
|
||
}
|
||
}
|
||
|
||
if (existsSync(resolve(root, 'resources/css/style.css'))) {
|
||
input.style = resolve(root, 'resources/css/style.css');
|
||
}
|
||
|
||
if (Object.keys(input).length === 0) {
|
||
throw new Error('Keine Oberfläche gefunden: Vue-Dateien gehören nach resources/js/<pages|widgets|blocks|profile|profile-panels|editorial>/.');
|
||
}
|
||
|
||
return {
|
||
plugins: [vue(), tailwindcss(), manifest(Object.keys(input))],
|
||
// Plugins laufen unter /plugin-assets/<slug>/<version>/ – Pfade relativ halten
|
||
base: './',
|
||
build: {
|
||
outDir: 'dist',
|
||
emptyOutDir: true,
|
||
target: 'es2022',
|
||
rollupOptions: {
|
||
input,
|
||
external: EXTERNAL,
|
||
preserveEntrySignatures: 'strict',
|
||
output: {
|
||
format: 'es',
|
||
entryFileNames: '[name].js',
|
||
chunkFileNames: 'chunks/[name]-[hash].js',
|
||
assetFileNames: 'assets/[name]-[hash][extname]',
|
||
},
|
||
},
|
||
},
|
||
};
|
||
}
|
||
|
||
/** dist/inhaus.json: welche Komponente in welcher Datei steckt, welches CSS dazugehört */
|
||
function manifest(entries) {
|
||
return {
|
||
name: 'inhaus-manifest',
|
||
generateBundle(_, bundle) {
|
||
const components = {};
|
||
const css = [];
|
||
|
||
for (const file of Object.values(bundle)) {
|
||
if (file.type === 'chunk' && file.isEntry && entries.includes(file.name) && file.name !== 'style') {
|
||
components[file.name] = file.fileName;
|
||
}
|
||
|
||
if (file.type === 'asset' && file.fileName.endsWith('.css')) {
|
||
css.push(file.fileName);
|
||
}
|
||
}
|
||
|
||
// Leere Hülle des CSS-Einstiegs nicht ausliefern
|
||
for (const [key, file] of Object.entries(bundle)) {
|
||
if (file.type === 'chunk' && file.name === 'style') delete bundle[key];
|
||
}
|
||
|
||
this.emitFile({ type: 'asset', fileName: 'inhaus.json', source: JSON.stringify({ components, css: [...new Set(css)] }, null, 4) });
|
||
},
|
||
};
|
||
}
|