import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import injectMetaTags from './injectMetaTags.vite.plugin.js';

export default defineConfig({
  plugins: [
    vue(),
    injectMetaTags([
      resolve('activation.html'),
      resolve('filemanager.html'),
      resolve('index.html'),
      resolve('oidc_login.html'),
      resolve('oidc_error.html'),
      resolve('oidc_interaction_confirm.html'),
      resolve('oidc_interaction_abort.html'),
      resolve('oidc_device_input.html'),
      resolve('oidc_device_confirm.html'),
      resolve('oidc_device_success.html'),
      resolve('logs.html'),
      resolve('passwordreset.html'),
      resolve('restore.html'),
      resolve('setup.html'),
      resolve('setupaccount.html'),
      resolve('terminal.html'),
    ]),
  ],
  server: {
    fs: {
      // Allow serving files from one level up to the project root for monaco editor assets
      allow: [ '../../../' ]
    },
  },
  // https://vitejs.dev/guide/build.html#multi-page-app
  build: {
    emptyOutDir: false, // we share dist/
    minify: false,
    rollupOptions: {
      input: {
        activation: resolve('activation.html'),
        appstatus: resolve('appstatus.html'),
        authcallback: resolve('authcallback.html'),
        filemanager: resolve('filemanager.html'),
        index: resolve('index.html'),
        oidc_login: resolve('oidc_login.html'),
        oidc_error: resolve('oidc_error.html'),
        oidc_interaction_confirm: resolve('oidc_interaction_confirm.html'),
        oidc_interaction_abort: resolve('oidc_interaction_abort.html'),
        oidc_device_input: resolve('oidc_device_input.html'),
        oidc_device_confirm: resolve('oidc_device_confirm.html'),
        oidc_device_success: resolve('oidc_device_success.html'),
        logs: resolve('logs.html'),
        notfound: resolve('notfound.html'),
        passwordreset: resolve('passwordreset.html'),
        restore: resolve('restore.html'),
        setup: resolve('setup.html'),
        setupaccount: resolve('setupaccount.html'),
        terminal: resolve('terminal.html'),
      },
    },
  },
});
