diff --git a/packages/module-api/vite.config.ts b/packages/module-api/vite.config.ts index 61f8fc5389..46af335695 100644 --- a/packages/module-api/vite.config.ts +++ b/packages/module-api/vite.config.ts @@ -11,6 +11,8 @@ import { defineConfig } from "vite"; import dts from "vite-plugin-dts"; import externalGlobals from "rollup-plugin-external-globals"; +import packageJson from "./package.json" with { type: "json" }; + const __dirname = dirname(fileURLToPath(import.meta.url)); export default defineConfig({ @@ -32,7 +34,9 @@ export default defineConfig({ }), ], define: { - __VERSION__: JSON.stringify(process.env.npm_package_version), + // 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" } },