|
1 | 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | +import { dirname, resolve } from "node:path"; |
3 | 4 | import { fileURLToPath } from "node:url"; |
4 | 5 |
|
5 | 6 | import react from "@vitejs/plugin-react"; |
6 | 7 | import { defineConfig } from "vite"; |
7 | 8 |
|
8 | | -const componentsPath = fileURLToPath(new URL("../lib/components", import.meta.url)); |
| 9 | +const __dirname = dirname(fileURLToPath(import.meta.url)); |
| 10 | + |
| 11 | +const chatComponentsPath = fileURLToPath(new URL("../lib/components", import.meta.url)); |
| 12 | + |
9 | 13 | const globalPackages = { |
10 | 14 | "@cloudscape-design/components": "components", |
11 | | - "@cloudscape-design/global-styles": "global-styles", |
12 | | - "@cloudscape-design/collection-hooks": "collection-hooks", |
13 | | - "@cloudscape-design/component-toolkit": "component-toolkit", |
14 | | - "@cloudscape-design/design-tokens": "design-tokens", |
15 | | - "@cloudscape-design/theming-runtime": "theming-runtime", |
| 15 | + "@cloudscape-design/global-styles": "globalStyles", |
| 16 | + "@cloudscape-design/component-toolkit": "componentToolkit", |
16 | 17 | }; |
17 | 18 |
|
18 | 19 | // https://vitejs.dev/config/ |
19 | 20 | export default defineConfig({ |
20 | 21 | plugins: [react({ fastRefresh: false })], |
21 | | - root: "./", |
22 | | - base: "./", |
23 | 22 | resolve: { |
24 | 23 | alias: { |
25 | 24 | lodash: "lodash-es", |
26 | 25 | }, |
27 | 26 | }, |
28 | 27 | build: { |
29 | | - outDir: "../lib/dev-pages/pages", |
| 28 | + lib: { |
| 29 | + entry: resolve(__dirname, "pages/main.tsx"), |
| 30 | + name: "ChatComponentsDevPages", |
| 31 | + fileName: "main", |
| 32 | + }, |
| 33 | + outDir: "lib/dev-pages/bundle", |
30 | 34 | rollupOptions: { |
31 | | - external: [componentsPath, ...Object.keys(globalPackages)], |
| 35 | + external: [chatComponentsPath, ...Object.keys(globalPackages)], |
32 | 36 | output: { |
33 | | - globals: { [componentsPath]: "chat-components", ...globalPackages }, |
34 | | - format: "iife", |
| 37 | + globals: { [chatComponentsPath]: "chatComponents", ...globalPackages }, |
35 | 38 | }, |
36 | 39 | }, |
37 | 40 | }, |
|
0 commit comments