Files
ThreadNet-Web/packages/module-api/vite.config.ts
T

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

45 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-01-27 10:07:35 +00: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-10 17:00:34 +01:00
import { defineConfig } from "vitest/config";
2026-04-22 12:28:54 +00:00
import dts from "unplugin-dts/vite";
2025-07-24 16:27:09 +01:00
import externalGlobals from "rollup-plugin-external-globals";
2025-01-27 10:07:35 +00:00
2026-04-21 22:47:07 +01:00
import packageJson from "./package.json" with { type: "json" };
2025-01-27 10:07:35 +00:00
const __dirname = dirname(fileURLToPath(import.meta.url));
2026-06-10 17:00:34 +01:00
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
name: "element-web-plugin-engine",
fileName: "element-web-plugin-engine",
2025-01-27 10:07:35 +00:00
},
2026-06-10 17:00:34 +01:00
outDir: "lib",
target: "esnext",
sourcemap: true,
},
plugins: [
dts(),
externalGlobals({
// Reuse React from the host app
react: "window.React",
}),
],
define: {
// We cannot use `process.env.npm_package_version` as when building element-web with module-api set to `workspace`
// this would contain the version of element-web rather than that of the module-api.
__VERSION__: JSON.stringify(packageJson.version),
// 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" } },
},
});