Skip to content
Snippets Groups Projects
Forked from 2024 Competition / Bielefeld-CeBiTec
2167 commits behind the upstream repository.
vite.config.js 1.08 KiB
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import { stringToSlug } from "./src/utils";
import path from 'path';

// https://vitejs.dev/config/
export default () => {
  const env = loadEnv("dev", process.cwd());
  if (!env.VITE_TEAM_NAME) {
    throw new Error("VITE_TEAM_NAME environment variable is not defined");
  }

  const baseSlug = stringToSlug(env.VITE_TEAM_NAME);
  console.log(`Base URL: /${baseSlug}/`);
  console.log(`Output directory: ${path.resolve(__dirname, 'dist')}`);

  

  return defineConfig({
    base: `/`,
    plugins: [react()],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'), // Simplifies imports
      }
    },
    css: {
      preprocessorOptions: {
        css: {
          //javascriptEnabled: true, // Enable JavaScript in CSS (useful for certain CSS preprocessor plugins)
        }
      }    },
    build: {
      outDir: "dist",
      rollupOptions: {
        output: {
          assetFileNames: `assets/[ext]/[name]-[hash].[ext]`
          }      
        }
      },
    publicDir: 'pubpub',
  });
};