keycloak-scim/js/apps/admin-ui/vite.config.ts
Erik Jan de Wit 0caca2d6f5
make admin-ui build as a library (#30268)
* make admin-ui build as a library

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* fix merge errors

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* fix input

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* added null check

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* renamed workspace

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

* PR review

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>

---------

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
2024-07-05 12:48:10 -04:00

58 lines
1.4 KiB
TypeScript

import react from "@vitejs/plugin-react-swc";
import path from "path";
import { defineConfig, loadEnv } from "vite";
import { checker } from "vite-plugin-checker";
import dts from "vite-plugin-dts";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const external = ["react", "react/jsx-runtime", "react-dom"];
const plugins = [react(), checker({ typescript: true })];
const input = env.LIB ? undefined : "src/main.tsx";
if (env.LIB) {
external.push("react-router-dom");
external.push("react-i18next");
plugins.push(dts({ insertTypesEntry: true }));
}
const lib = env.LIB
? {
outDir: "lib",
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
formats: ["es"],
},
}
: {
outDir: "target/classes/theme/keycloak.v2/admin/resources",
};
return {
base: "",
server: {
origin: "http://localhost:5174",
port: 5174,
},
build: {
...lib,
sourcemap: true,
target: "esnext",
modulePreload: false,
cssMinify: "lightningcss",
manifest: true,
rollupOptions: {
input,
external,
},
},
plugins,
test: {
watch: false,
environment: "jsdom",
server: {
deps: {
inline: [/@patternfly\/.*/],
},
},
},
};
});