Add resources defined in config and a bundle of the site's own screens

This commit is contained in:
Matthijs Iriks committed 2026-12-04 05:26:37 +01:00
1 parent 37a29d9195
commit 3345797141
35 files changed
+905 -19

No files matched your search

+17 -2
View File
@@ -1,11 +1,26 @@
import tailwindcss from '@tailwindcss/vite';
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
import { defineConfig, type Plugin } from 'vite';
// One script and one stylesheet with fixed names: the package serves them itself (resources/dist), so a site needs
// no Node. `npm run build` here, and commit the result.
// A site's own bundle imports `vue` like any component library would. `vue.js` makes that the Vue of the screens (an import map
// in the shell points `vue` at it), by re-exporting what the screens put on `window.IriksManager.Vue`.
function vueForExtensions(): Plugin {
return {
name: 'manager-vue-for-extensions',
async generateBundle() {
const loaded: Record<string, unknown> = await import('vue');
const names = [...new Set([...Object.keys(loaded), ...Object.keys((loaded.default as object) ?? {})])].filter((name) => /^[A-Za-z_$][\w$]*$/.test(name) && name !== 'default');
const source = `const Vue = window.IriksManager.Vue;\n${names.map((name) => `export const ${name} = Vue.${name};`).join('\n')}\nexport default Vue;\n`;
this.emitFile({ type: 'asset', fileName: 'vue.js', source });
},
};
}
export default defineConfig({
plugins: [vue(), tailwindcss()],
plugins: [vue(), tailwindcss(), vueForExtensions()],
build: {
outDir: '../resources/dist',
emptyOutDir: true,