-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
78 lines (76 loc) · 2.19 KB
/
Copy pathvite.config.ts
File metadata and controls
78 lines (76 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import react from "@vitejs/plugin-react-swc";
import { resolve } from "path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { libInjectCss } from "vite-plugin-lib-inject-css";
import preserveDirectives from "rollup-preserve-directives";
export default defineConfig(({ command }) => {
// Dev mode: serve the demo app
if (command === "serve") {
return {
root: resolve(__dirname, "demo"),
plugins: [react()],
resolve: {
alias: {
// Deduplicate React and related packages to avoid issues
// when using local file: dependencies
react: resolve(__dirname, "node_modules/react"),
"react-dom": resolve(__dirname, "node_modules/react-dom"),
"react/jsx-runtime": resolve(__dirname, "node_modules/react/jsx-runtime"),
"react-i18next": resolve(__dirname, "node_modules/react-i18next"),
"i18next": resolve(__dirname, "node_modules/i18next"),
},
},
server: {
port: 5173,
open: true,
},
};
}
// Build mode: build the library
return {
plugins: [
react(),
libInjectCss(),
dts({
insertTypesEntry: true,
rollupTypes: true,
}),
],
build: {
lib: {
entry: {
"keycloak-react": resolve(__dirname, "src/index.ts"),
"server": resolve(__dirname, "src/server.ts"),
"client": resolve(__dirname, "src/client.ts"),
"account": resolve(__dirname, "src/account.ts"),
},
name: "KeycloakReact",
formats: ["es"],
},
rollupOptions: {
// Externalize all dependencies that shouldn't be bundled
external: [
"react",
"react-dom",
"react/jsx-runtime",
"next-auth",
"next-auth/react",
"next-auth/jwt",
"next-auth/providers/keycloak",
"next/server",
"next/headers",
/^@patternfly\/.*/,
],
plugins: [preserveDirectives()],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "jsxRuntime",
},
},
},
},
};
});