import { defineConfig } from "vite";
{% if include_vue %}import vue from "@vitejs/plugin-vue";{% endif %}
{% if include_react %}import react from "@vitejs/plugin-react";{% endif %}
import litestar from "litestar-vite-plugin";

const ASSET_URL = process.env.ASSET_URL || "{{ asset_url }}";
const VITE_PORT = process.env.VITE_PORT || "5173";
const VITE_HOST = process.env.VITE_HOST || "localhost";
export default defineConfig({
  base: `${ASSET_URL}`,
  {% if root_path and root_path != '.' %} root: "{{ root_path }}",{% endif %}
  server: {
    host: "0.0.0.0",
    port: +`${VITE_PORT}`,
    cors: true,
    hmr: {
      host: `${VITE_HOST}`,
    },
  },
  plugins: [
    {% if include_vue %}vue(),{% endif %}
    {% if include_react %}react(),{% endif %}
    litestar({
      input: [
        {% if entry_point %}"{{ entry_point | join('\", \"') }}"{% endif %}
      ],
      assetUrl: `${ASSET_URL}`,
      bundleDirectory: "{{ bundle_path }}",
      resourceDirectory: "{{ resource_path }}",
      hotFile: "{{ hot_file }}"
    }),
  ],
  resolve: {
    alias: {
      "@": "{{ resource_path }}"
    },
  },
});
