Files
romm/frontend/vite.config.js
Georges-Antoine Assi 805a688366 update vite config
2024-08-05 11:18:55 -04:00

89 lines
2.2 KiB
JavaScript

// Plugins
import vue from "@vitejs/plugin-vue";
import { VitePWA } from "vite-plugin-pwa";
import { viteStaticCopy } from "vite-plugin-static-copy";
import vuetify, { transformAssetUrls } from "vite-plugin-vuetify";
// Utilities
import { URL, fileURLToPath } from "node:url";
import { defineConfig, loadEnv } from "vite";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load ENV variables from the parent directory and the current directory.
const env = { ...loadEnv(mode, "../"), ...loadEnv(mode, "./") };
const backendPort = env.VITE_BACKEND_DEV_PORT ?? "5000";
return {
build: {
target: "esnext",
},
plugins: [
vue({
template: { transformAssetUrls },
}),
vuetify({
autoImport: true,
styles: {
configFile: "src/styles/settings.scss",
},
}),
VitePWA({
injectRegister: null,
manifest: {
icons: [
{
src: "favicon.ico",
sizes: "256x256",
type: "image/ico",
purpose: "any maskable",
},
],
},
devOptions: {
enabled: true,
type: "module",
},
}),
viteStaticCopy({
targets: [
{
src: "node_modules/emulatorjs/data/*",
dest: "assets/emulatorjs/",
},
],
}),
],
define: {
"process.env": {},
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: true,
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
extensions: [".js", ".json", ".jsx", ".mjs", ".ts", ".tsx", ".vue"],
},
server: {
proxy: {
"/api": {
target: `http://127.0.0.1:${backendPort}`,
changeOrigin: false,
secure: false,
},
"/ws": {
target: `http://127.0.0.1:${backendPort}`,
changeOrigin: false,
ws: true,
},
"/openapi.json": {
target: `http://127.0.0.1:${backendPort}`,
changeOrigin: false,
rewrite: (path) => path.replace(/^\/openapi.json/, "/openapi.json"),
},
},
port: 3000,
},
};
});