import { resolve } from 'path'
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import commonjs from '@rollup/plugin-commonjs';


// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
    ],
    build: {
        outDir: "../static/aircox/",
        sourcemap: true,

        rollupOptions: {
            external: ['vue',],
            input: {
                public: "src/public.js",
                admin: "src/admin.js",
            },
            output: {
                globals: {
                    vue: 'Vue',
                },
                assetFileNames: "[name].[ext]",
                chunkFileNames: "[name].js",
                entryFileNames: "[name].js",
            },
            plugins: [commonjs()],
        },
    },
    css: {
        devSourcemap: true,
    },
    resolve: {
        extensions: ['.js', '.ts', '.json', '.vue'],
        alias: {
          '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    }
})
