mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import path from "path";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import { swPrecacheManifest } from "./plugins/sw-precache-manifest";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, path.resolve(__dirname, ".."), "");
|
|
const backendPort = env.PORT || 5001;
|
|
|
|
return {
|
|
envDir: path.resolve(__dirname, ".."),
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
swPrecacheManifest(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: 5173,
|
|
proxy: {
|
|
"/api": {
|
|
target: `http://localhost:${backendPort}`,
|
|
changeOrigin: true,
|
|
ws: true,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
assetsInlineLimit: 4096,
|
|
rollupOptions: {
|
|
input: {
|
|
main: path.resolve(__dirname, "index.html"),
|
|
},
|
|
output: {
|
|
entryFileNames: "assets/[name]-[hash].js",
|
|
assetFileNames: (assetInfo) => {
|
|
if (assetInfo.name === "manifest.json") {
|
|
return "manifest.json";
|
|
}
|
|
return "assets/[name]-[hash][extname]";
|
|
},
|
|
},
|
|
},
|
|
},
|
|
preview: {
|
|
host: "0.0.0.0",
|
|
port: 5173,
|
|
},
|
|
worker: {
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: "sw.js",
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|