Spaces:
Running
Running
File size: 1,989 Bytes
0d9f1af b664dbe 0d9f1af b664dbe 0d9f1af b664dbe 0d9f1af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import { existsSync } from "fs";
export default defineConfig(({ mode }) => {
// Check if we're in a workspace environment (has packages/web/src)
const isWorkspace = existsSync(resolve(__dirname, "./packages/web/src"));
const baseConfig = {
plugins: [],
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
// Only add workspace alias if in workspace environment
...(isWorkspace && {
"@lerobot/web": resolve(__dirname, "./packages/web/src"),
}),
},
},
};
if (mode === "demo") {
// React demo mode - includes React, Tailwind, shadcn/ui
return {
...baseConfig,
plugins: [react()],
css: {
postcss: "./postcss.config.mjs",
},
build: {
outDir: "dist/demo",
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
},
},
},
};
}
if (mode === "vanilla") {
// Vanilla mode - current implementation without React
return {
...baseConfig,
build: {
outDir: "dist/vanilla",
rollupOptions: {
input: {
main: resolve(__dirname, "vanilla.html"),
},
},
},
};
}
if (mode === "lib") {
// Library mode - core library without any demo UI
return {
...baseConfig,
build: {
lib: {
entry: resolve(__dirname, "src/main.ts"),
name: "LeRobot",
fileName: "lerobot",
},
rollupOptions: {
external: ["serialport", "react", "react-dom"],
output: {
globals: {
serialport: "SerialPort",
react: "React",
"react-dom": "ReactDOM",
},
},
},
},
};
}
// Default mode (fallback to demo)
return defineConfig({ mode: "demo" });
});
|