import { defineConfig } from 'vite';
import path from 'path';

const rootDir = __dirname;

export default defineConfig({
  root: rootDir,
  base: '/town-editor/',
  publicDir: path.resolve(rootDir, '../../frontend/public'),
  resolve: {
    alias: {
      '@game': path.resolve(rootDir, '../../frontend/src/game'),
      '@shared': path.resolve(rootDir, '../../frontend/src/shared'),
      '@frontend': path.resolve(rootDir, '../../frontend/src'),
      'pixi.js': path.resolve(rootDir, 'node_modules/pixi.js'),
    },
    dedupe: ['pixi.js'],
  },
  server: {
    port: 5175,
    fs: {
      allow: [
        path.resolve(rootDir, '../../frontend'),
        path.resolve(rootDir, '../../admin-web/town-editor'),
      ],
    },
  },
  build: {
    outDir: 'dist',
    emptyOutDir: true,
  },
});
