2023-02-14 15:57:58 +00:00
|
|
|
import react from "@vitejs/plugin-react-swc";
|
2024-07-05 16:48:10 +00:00
|
|
|
import path from "path";
|
|
|
|
import { defineConfig, loadEnv } from "vite";
|
2022-11-18 16:13:39 +00:00
|
|
|
import { checker } from "vite-plugin-checker";
|
2024-07-05 16:48:10 +00:00
|
|
|
import dts from "vite-plugin-dts";
|
2022-07-07 05:23:54 +00:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2024-07-05 16:48:10 +00:00
|
|
|
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",
|
2024-10-29 12:33:35 +00:00
|
|
|
external: ["src/index.ts"],
|
2024-07-05 16:48:10 +00:00
|
|
|
};
|
|
|
|
return {
|
|
|
|
base: "",
|
2024-05-06 11:21:32 +00:00
|
|
|
server: {
|
2024-07-05 16:48:10 +00:00
|
|
|
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\/.*/],
|
|
|
|
},
|
2024-05-06 11:21:32 +00:00
|
|
|
},
|
|
|
|
},
|
2024-07-05 16:48:10 +00:00
|
|
|
};
|
2022-07-07 05:23:54 +00:00
|
|
|
});
|