Files
ThreadNet-Web/modules/restricted-guests/vite.config.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-08-12 14:12:57 +01:00
/*
Copyright 2025 New Vector 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";
2026-06-04 11:11:29 +01:00
import { defineConfig, esmExternalRequirePlugin } from "vite";
2025-08-12 14:12:57 +01:00
import react from "@vitejs/plugin-react";
import { nodePolyfills } from "vite-plugin-node-polyfills";
2026-06-04 12:47:25 +01:00
import externalGlobals from "rollup-plugin-external-globals";
2025-12-02 09:40:02 +00:00
import { importCSSSheet } from "@arcmantle/vite-plugin-import-css-sheet";
2025-08-12 14:12:57 +01:00
const __dirname = dirname(fileURLToPath(import.meta.url));
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.tsx"),
name: "element-web-module-restricted-guests",
fileName: "index",
formats: ["es"],
},
outDir: "lib",
target: "esnext",
sourcemap: true,
2026-06-04 11:11:29 +01:00
rolldownOptions: {
plugins: [
esmExternalRequirePlugin({
external: ["react"],
}),
],
2026-06-04 11:36:15 +01:00
output: {
globals: {
// Reuse React from the host app
react: "window.React",
},
},
2025-08-12 14:12:57 +01:00
},
},
plugins: [
2025-12-02 09:40:02 +00:00
importCSSSheet(),
2025-08-12 14:12:57 +01:00
react(),
nodePolyfills({
include: ["events"],
}),
2026-06-04 12:47:25 +01:00
externalGlobals({
// Reuse React from the host app
react: "window.React",
}),
2025-08-12 14:12:57 +01:00
],
2026-06-04 13:42:01 +01:00
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'",
"process": { env: { NODE_ENV: "production" } },
},
2025-08-12 14:12:57 +01:00
});