|
3 | 3 | * SPDX-License-Identifier: Apache-2.0 |
4 | 4 | */ |
5 | 5 |
|
6 | | -import react from "@vitejs/plugin-react"; |
7 | | -import { keycloakify } from "keycloakify/vite-plugin"; |
8 | | -import path from "path"; |
9 | | -import { defineConfig } from "vite"; |
10 | | -import { viteStaticCopy } from "vite-plugin-static-copy"; |
11 | | -import svgr from "vite-plugin-svgr"; |
| 6 | +import react from '@vitejs/plugin-react'; |
| 7 | +import { keycloakify } from 'keycloakify/vite-plugin'; |
| 8 | +import { createRequire } from 'module'; |
| 9 | +import path from 'path'; |
| 10 | +import { defineConfig } from 'vite'; |
| 11 | +import { viteStaticCopy } from 'vite-plugin-static-copy'; |
| 12 | +import svgr from 'vite-plugin-svgr'; |
12 | 13 |
|
13 | | -const THEME_NAME_AGENTSTACK = "agentstack"; |
14 | | -const THEME_NAME_AGENTSTACK_SSO = "agentstack-sso"; |
| 14 | +const THEME_NAME_AGENTSTACK = 'agentstack'; |
| 15 | +const THEME_NAME_AGENTSTACK_SSO = 'agentstack-sso'; |
| 16 | +const require = createRequire(import.meta.url); |
| 17 | + |
| 18 | +const resolvePackageDir = (packageName: string) => path.dirname(require.resolve(`${packageName}/package.json`)); |
15 | 19 |
|
16 | 20 | export default defineConfig({ |
17 | 21 | define: { |
18 | | - "import.meta.env.VITE_APP_NAME": JSON.stringify( |
19 | | - process.env.APP_NAME || "Agent Stack", |
20 | | - ), |
| 22 | + 'import.meta.env.VITE_APP_NAME': JSON.stringify(process.env.APP_NAME || 'Agent Stack'), |
21 | 23 | }, |
22 | 24 | plugins: [ |
23 | 25 | react(), |
24 | 26 | svgr(), |
25 | 27 | viteStaticCopy({ |
26 | 28 | targets: [ |
27 | 29 | { |
28 | | - src: path.join( |
29 | | - __dirname, |
30 | | - "node_modules/@ibm/plex/IBM-Plex-Sans/fonts/split/woff2/*.woff2", |
31 | | - ), |
32 | | - dest: "assets/~@ibm/plex/IBM-Plex-Sans/fonts/split/woff2", |
| 30 | + src: path.join(__dirname, 'node_modules/@ibm/plex/IBM-Plex-Sans/fonts/split/woff2/*.woff2'), |
| 31 | + dest: 'assets/~@ibm/plex/IBM-Plex-Sans/fonts/split/woff2', |
33 | 32 | }, |
34 | 33 | ], |
35 | 34 | }), |
36 | 35 | keycloakify({ |
37 | | - accountThemeImplementation: "none", |
| 36 | + accountThemeImplementation: 'none', |
38 | 37 | themeName: [THEME_NAME_AGENTSTACK, THEME_NAME_AGENTSTACK_SSO], |
39 | 38 | }), |
40 | 39 | ], |
41 | 40 | css: { |
42 | 41 | modules: { |
43 | | - generateScopedName: "[name]__[local]__[hash:base64:5]", |
| 42 | + generateScopedName: '[name]__[local]__[hash:base64:5]', |
44 | 43 | }, |
45 | 44 | preprocessorOptions: { |
46 | 45 | scss: { |
47 | | - api: "modern", |
| 46 | + api: 'modern', |
48 | 47 | quietDeps: true, |
49 | 48 | additionalData: `@use 'styles/common' as *; @use 'sass:math';`, |
50 | 49 | includePaths: [ |
51 | | - path.join(__dirname, "node_modules"), |
52 | | - path.join(__dirname, "src"), |
53 | | - path.join(__dirname, "../agentstack-ui/src"), |
| 50 | + path.join(__dirname, 'node_modules'), |
| 51 | + path.join(__dirname, 'src'), |
| 52 | + path.join(__dirname, '../agentstack-ui/src'), |
54 | 53 | ], |
55 | | - loadPaths: [path.join(__dirname, "../agentstack-ui/src")], |
| 54 | + loadPaths: [path.join(__dirname, '../agentstack-ui/src')], |
56 | 55 | }, |
57 | 56 | }, |
58 | 57 | }, |
59 | 58 | resolve: { |
| 59 | + dedupe: ['react', 'react-dom'], |
60 | 60 | alias: { |
61 | | - styles: path.resolve(__dirname, "../agentstack-ui/src/styles"), |
| 61 | + react: resolvePackageDir('react'), |
| 62 | + 'react/jsx-runtime': require.resolve('react/jsx-runtime'), |
| 63 | + 'react/jsx-dev-runtime': require.resolve('react/jsx-dev-runtime'), |
| 64 | + 'react-dom': resolvePackageDir('react-dom'), |
| 65 | + styles: path.resolve(__dirname, '../agentstack-ui/src/styles'), |
62 | 66 | }, |
63 | 67 | }, |
64 | 68 | }); |
0 commit comments