ci: initial backend vite config

This commit is contained in:
Derrick Hammer 2023-07-17 10:36:05 -04:00
parent 5b844b5c6d
commit 2c2fe874be
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 47 additions and 0 deletions

47
vite.config.js Normal file
View File

@ -0,0 +1,47 @@
import { defineConfig } from "vite";
import optimizer from "vite-plugin-optimizer";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import { resolve } from "path";
const config = {};
const currentConfig = config[process.env.LIB_NAME];
if (currentConfig === undefined) {
throw new Error("LIB_NAME is not defined or is not valid");
}
["background", "bootloader", "bridge", "crypto", "cryptoLoader"].forEach(
(item) => {
config[item] = {
entry: resolve(__dirname, `./src/main/${item}.ts`),
fileName: "math.js",
};
},
);
export default defineConfig({
build: {
outDir: "lib",
lib: {
entry: "build/index.js",
name: "main",
formats: ["cjs"],
...currentConfig,
},
minify: false,
rollupOptions: { output: { inlineDynamicImports: true } },
},
resolve: {
dedupe: ["@lumeweb/libportal", "@lumeweb/libweb", "@lumeweb/libkernel"],
},
plugins: [
optimizer({
"node-fetch":
"const e = undefined; export default e;export {e as Response, e as FormData, e as Blob};",
}),
nodePolyfills({
exclude: ["fs"],
globals: { Buffer: true, global: true, process: true },
}),
],
});