30abf86c4b
* API: https://github.com/element-hq/element-modules/pull/219 * Element Web API impl: https://github.com/element-hq/element-web/pull/32734
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-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";
|
|
import react from "@vitejs/plugin-react";
|
|
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
import externalGlobals from "rollup-plugin-external-globals";
|
|
import svgr from "vite-plugin-svgr";
|
|
import { importCSSSheet } from "@arcmantle/vite-plugin-import-css-sheet";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
export default defineConfig({
|
|
build: {
|
|
lib: {
|
|
entry: resolve(__dirname, "src/index.tsx"),
|
|
name: "element-web-module-widget-toggles",
|
|
fileName: "index",
|
|
formats: ["es"],
|
|
},
|
|
outDir: "lib",
|
|
target: "esnext",
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
external: ["react"],
|
|
},
|
|
},
|
|
plugins: [
|
|
importCSSSheet(),
|
|
react(),
|
|
svgr(),
|
|
nodePolyfills({
|
|
include: ["events"],
|
|
}),
|
|
externalGlobals({
|
|
// Reuse React from the host app
|
|
react: "window.React",
|
|
}),
|
|
],
|
|
define: {
|
|
// Use production mode for the build as it is tested against production builds of Element Web,
|
|
// this is required for React JSX versions to be compatible.
|
|
process: { env: { NODE_ENV: "production" } },
|
|
},
|
|
});
|