Files
github-stats-extended/apps/frontend/vite.config.ts
T
MartinandMarco Pasqualetti f64b56ae9a backend tests in ci, clean pg import (#71)
- run backend tests in CI
- clean `pg` import
- fix cyclic dependency
- fix dotenv import

---------

Co-authored-by: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com>
2026-02-10 08:50:43 +01:00

79 lines
1.6 KiB
TypeScript

import path from "node:path";
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import StringReplace from "vite-plugin-string-replace";
// https://vitejs.dev/config/
export default defineConfig({
base: "/frontend/",
plugins: [
StringReplace([
{
search: "process.env",
replace: "window.process.env",
fileName: ".*backend.*",
},
]),
nodePolyfills({
include: [
"path",
"querystring",
"url",
"http",
"util",
"stream",
"buffer",
],
exclude: ["fs", "net"],
}),
react(),
/**
* mock pg (postgres) package in the browser to avoid runtime errors
* @see apps/backend/src/common/database.js
*/
{
name: "empty-pg-package",
resolveId(id) {
if (id === "pg") {
return id;
}
return undefined;
},
load(id) {
if (id === "pg") {
return "export class Pool { constructor(config) {} }";
}
return undefined;
},
},
],
build: {
outDir: "build",
/** @todo use chunks to split bundle? */
chunkSizeWarningLimit: 800,
},
resolve: {
alias: [
{
find: "dotenv",
replacement: path.resolve(
import.meta.dirname,
"src/dotenv-browser-stub.ts",
),
},
{
find: "../src/fetchers/wakatime.js",
replacement: path.resolve(
import.meta.dirname,
"src/wakatime-override.ts",
),
},
],
},
});