Files
element-web/packages/module-api/vite.base.ts
T
Michael Telatynski cf9ee41d06 DRY
2026-06-08 11:19:13 +01:00

47 lines
1.3 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.
*/
/**
* Base vite config for building Element modules
*/
import { defineConfig, esmExternalRequirePlugin } from "vite";
import externalGlobals from "rollup-plugin-external-globals";
export default defineConfig({
build: {
outDir: "lib",
target: "esnext",
sourcemap: true,
rolldownOptions: {
plugins: [
esmExternalRequirePlugin({
external: ["react"],
}),
],
output: {
globals: {
// Reuse React from the host app
react: "window.React",
},
},
},
},
plugins: [
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'",
"process": { env: { NODE_ENV: "production" } },
},
});