/*
 * @Author: zengzhe
 * @Date: 2024-12-27 11:48:34
 * @LastEditors: xiejiang
 * @LastEditTime: 2025-03-04 14:12:00
 * @Description:
 */
import { resolve } from 'path'
import { defineConfig, loadEnv } from '@rsbuild/core'
import { createPlugins } from './build/rsbuild-plugins'
import { wrapperEnv } from './build/getEnv'

const { publicVars } = loadEnv({ prefixes: ['PUBLIC_'] })
const Envs = wrapperEnv(publicVars)

export default defineConfig({
  root: process.cwd(),
  server: {
    base: Envs.PUBLIC_PUBLIC_PATH,
    port: Envs.PUBLIC_PORT,
    open: Envs.PUBLIC_OPEN,
    cors: true
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
    }
  },
  html: {
    title: '',
    template: './index.html'
  },
  source: {
    entry: {
      index: './src/main.ts'
    }
  },
  output: {
    distPath: {
      root: 'dist'
    },
    minify: true
  },
  plugins: createPlugins().plugins,
  tools: createPlugins().tools,
  // moduleFederation: createPlugins().moduleFederation,
  performance: {
    removeConsole: true
  }
})
