Keycloak
45 строк · 1.1 Кб
1import react from "@vitejs/plugin-react-swc";
2import path from "path";
3import { defineConfig, loadEnv } from "vite";
4import { checker } from "vite-plugin-checker";
5import dts from "vite-plugin-dts";
6
7import { getRootPath } from "./src/utils/getRootPath";
8
9// https://vitejs.dev/config/
10export default defineConfig(({ mode }) => {
11const env = loadEnv(mode, process.cwd(), "");
12const external = ["react", "react/jsx-runtime", "react-dom"];
13const plugins = [react(), checker({ typescript: true })];
14if (env.LIB) {
15external.push("react-router-dom");
16external.push("react-i18next");
17plugins.push(dts({ insertTypesEntry: true }));
18}
19const lib = env.LIB
20? {
21lib: {
22entry: path.resolve(__dirname, "src/index.ts"),
23formats: ["es"],
24},
25}
26: undefined;
27return {
28base: "",
29server: {
30port: 8080,
31open: getRootPath(),
32},
33build: {
34...lib,
35sourcemap: true,
36target: "esnext",
37modulePreload: false,
38cssMinify: "lightningcss",
39rollupOptions: {
40external: external,
41},
42},
43plugins,
44};
45});
46