Files
lucia-frontend/vite.config.js
2026-03-08 12:11:57 +08:00

58 lines
1.6 KiB
JavaScript

// The Lucia project.
// Copyright 2023-2026 DSP, inc. All rights reserved.
// Authors:
// chiayin.kuo@dsp.im (chiayin), 2023/1/31
// cindy.chang@dsp.im (Cindy Chang), 2024/7/9
// imacat.yang@dsp.im (imacat), 2026/3/6
/**
* @module vite.config
* Vite build configuration with dev server proxy,
* path aliases, and test environment settings.
*/
import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
cacheDir: env.VITE_CACHE_DIR || undefined,
plugins: [vue()],
base: "/",
resolve: {
alias: {
util: "util/",
"@": fileURLToPath(new URL("./src", import.meta.url)),
"/images": "src/assets/images",
},
},
server: {
host: "localhost",
port: 58249,
proxy: {
"/api": {
target: env.VUE_APP_API_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
optimizeDeps: {
include: ["vue", "vue-router", "pinia", "axios"],
},
build: {
commonjsOptions: {
transformMixedEsModules: true, // Enable @walletconnect/web3-provider which has some code in CommonJS
// esmExternals: true, // If you set esmExternals to true, this plugins assumes that all external dependencies are ES modules
},
},
test: {
globals: true,
environment: "jsdom",
// reporter: ['text', 'json', 'html', 'vue'],
},
};
});