From 832d7ed43f815ee8799570233bd0406736ad3810 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Thu, 2 Oct 2025 17:44:31 +0200 Subject: [PATCH] chore: build shared components as a lib --- src/shared-components/index.ts | 17 ++++++++++++++ vite.config.js | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/shared-components/index.ts create mode 100644 vite.config.js diff --git a/src/shared-components/index.ts b/src/shared-components/index.ts new file mode 100644 index 0000000000..78d01946ad --- /dev/null +++ b/src/shared-components/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2025 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial + * Please see LICENSE files in the repository root for full details. + */ + +export * from "./audio/AudioPlayerView"; +export * from "./audio/Clock"; +export * from "./audio/PlayPauseButton"; +export * from "./audio/SeekBar"; +export * from "./avatar/AvatarWithDetails"; +export * from "./event-tiles/TextualEventView"; +export * from "./message-body/MediaBody"; +export * from "./pill-input/Pill"; +export * from "./pill-input/PillInput"; +export * from "./rich-list/RichItem"; diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000000..c8ed69c0cf --- /dev/null +++ b/vite.config.js @@ -0,0 +1,41 @@ +/* + * Copyright 2025 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial + * Please see LICENSE files in the repository root for full details. + */ + +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import { defineConfig } from "vite"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export default defineConfig({ + build: { + lib: { + entry: resolve(__dirname, "src/shared-components/index.ts"), + name: "Element Web Shared Components", + // the proper extensions will be added + fileName: "element-web-shared-components", + }, + rollupOptions: { + // make sure to externalize deps that shouldn't be bundled + // into your library + external: ["react"], + output: { + // Provide global variables to use in the UMD build + // for externalized deps + globals: { + react: "react", + }, + }, + }, + }, + resolve: { + alias: { + // Alias used by i18n.tsx + $webapp: resolve(__dirname, "webapp"), + }, + }, +});