(feat): prepare for new ident flow
(fix): some bugs
This commit is contained in:
parent
20018f09a9
commit
8e831fd993
8 changed files with 177 additions and 232 deletions
|
|
@ -3,7 +3,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
import { defineConfig, normalizePath, type Plugin } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { mtp } from "mtp/vite";
|
||||
|
|
@ -51,6 +51,38 @@ function deepFilterAssetHeaders(rootDir: string): Plugin {
|
|||
};
|
||||
}
|
||||
|
||||
function restartOnMtpSourceChange(srcDir: string): Plugin {
|
||||
const watchedDir = normalizePath(realpathSync(srcDir));
|
||||
|
||||
return {
|
||||
name: "restart-on-mtp-source-change",
|
||||
apply: "serve",
|
||||
configureServer(server) {
|
||||
server.watcher.add(watchedDir);
|
||||
let restartTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const restart = (file: string) => {
|
||||
if (!normalizePath(file).startsWith(`${watchedDir}/`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (restartTimer) {
|
||||
clearTimeout(restartTimer);
|
||||
}
|
||||
|
||||
restartTimer = setTimeout(() => {
|
||||
restartTimer = null;
|
||||
void server.restart();
|
||||
}, 50);
|
||||
};
|
||||
|
||||
server.watcher.on("add", restart);
|
||||
server.watcher.on("change", restart);
|
||||
server.watcher.on("unlink", restart);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
base: "./",
|
||||
clearScreen: false,
|
||||
|
|
@ -105,7 +137,6 @@ export default defineConfig({
|
|||
},
|
||||
envPrefix: ["VITE_", "TAURI_ENV_*"],
|
||||
optimizeDeps: {
|
||||
// Annoying Vite 8 stuff
|
||||
include: [
|
||||
"react-redux",
|
||||
"use-sync-external-store/shim/with-selector",
|
||||
|
|
@ -114,7 +145,28 @@ export default defineConfig({
|
|||
"eventemitter3",
|
||||
"react-is",
|
||||
],
|
||||
exclude: ["mtp", "mtp/raw", "mtp/type-map", "@tensamin/shared"],
|
||||
exclude: [
|
||||
"mtp",
|
||||
"mtp/raw",
|
||||
"mtp/type-map",
|
||||
"@tensamin/call",
|
||||
"@tensamin/call/utils",
|
||||
"@tensamin/chat",
|
||||
"@tensamin/crypto",
|
||||
"@tensamin/crypto/context",
|
||||
"@tensamin/crypto/worker",
|
||||
"@tensamin/markdown",
|
||||
"@tensamin/mtp",
|
||||
"@tensamin/notifications",
|
||||
"@tensamin/shared",
|
||||
"@tensamin/shared/data",
|
||||
"@tensamin/shared/log",
|
||||
"@tensamin/storage",
|
||||
"@tensamin/storage/context",
|
||||
"@tensamin/tauri",
|
||||
"@tensamin/tauth",
|
||||
"@tensamin/user",
|
||||
],
|
||||
},
|
||||
build: {
|
||||
minify: !process.env.TAURI_ENV_DEBUG ? "esbuild" : false,
|
||||
|
|
@ -122,6 +174,7 @@ export default defineConfig({
|
|||
},
|
||||
plugins: [
|
||||
deepFilterAssetHeaders(resolve(appDir, "public")),
|
||||
restartOnMtpSourceChange(resolve(appDir, "../../packages/mtp/src")),
|
||||
mtp({ typeMaps: resolve(appDir, "../../type-maps.yaml") }),
|
||||
react(),
|
||||
tailwindcss(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue