REST Service for POPCORN - ILIAS
alex
2025-06-04 6cb1d311f04d1f68f2d194524974b0f7bc0d31bd
vite.config.js
@@ -1,29 +1,40 @@
import { fileURLToPath, URL } from 'node:url'
import {fileURLToPath, URL} from 'node:url'
import * as path from 'node:path'
import { defineConfig } from 'vite'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import dotenv from 'dotenv'
let envPath = path.resolve(process.cwd(), "vue", '.env')
if (process.env.VITE_ENV == 'production') {
   envPath += ".production"
}
console.log("> envPath", envPath)
dotenv.config({path: envPath})
const routerBase = `${process.env.VITE_ROUTER_BASE}/ui`
console.log("+ ROUTER BASE IS", routerBase)
// https://vite.dev/config/
export default defineConfig({
  base: "/ui",
  root: path.join(__dirname, 'vue'),
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./vue/src', import.meta.url))
    },
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:4101',
        changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/api/, ''),
   base: routerBase,
   root: path.join(__dirname, 'vue'),
   plugins: [
      vue(),
      vueDevTools(),
   ],
   resolve: {
      alias: {
         '@': fileURLToPath(new URL('./vue/src', import.meta.url))
      },
    },
  },
   },
   server: {
      proxy: {
         '/api': {
            target: 'http://localhost:4101',
            changeOrigin: true,
            // rewrite: (path) => path.replace(/^\/api/, ''),
         },
      },
   },
})