DRY
This commit is contained in:
@@ -19,10 +19,15 @@
|
||||
"types": "./lib/element-web-module-api-alpha.d.ts",
|
||||
"import": "./lib/element-web-plugin-engine.js",
|
||||
"require": "./lib/element-web-plugin-engine.umd.cjs"
|
||||
},
|
||||
"./vite.base.ts": {
|
||||
"types": "./vite.base.ts",
|
||||
"import": "./vite.base.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
"lib",
|
||||
"vite.base.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"prepack": "nx build",
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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" } },
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user