- schema-profili: il test pretendeva che lo slot g1 fosse libero, ma in produzione è collegato a un giocatore vero; ora verifica che il tentativo anonimo non cambi il valore. - rosa: il default dei voti MVP era fuori da useMemo e faceva ricalcolare la rosa a ogni render finché i voti non erano caricati. - test dei badge, profili-core, push-sw, scout-stato: tipi allineati al codice (MappaPresenze, nascita da M18, renotify, narrowing di deepEqual). - vite.config: tipizzato come UserConfig e rimosso esbuild.keepNames, ignorato da Vite 8 che non usa più esbuild. - formattazione Prettier in BarraSottosezioni e classifica. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import { defineConfig, loadEnv, mergeConfig, type UserConfig } from "vite";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import tsConfigPaths from "vite-tsconfig-paths";
|
|
import viteReact from "@vitejs/plugin-react";
|
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
import { devtools } from "@tanstack/devtools-vite";
|
|
|
|
export default defineConfig(async ({ command, mode }) => {
|
|
const isDevBuild = command === "build" && mode === "development";
|
|
|
|
const loadedEnv = loadEnv(mode, process.cwd(), "VITE_");
|
|
const envDefine: Record<string, string> = {};
|
|
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
envDefine[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
}
|
|
|
|
const plugins = [];
|
|
if (mode === "development") {
|
|
plugins.push(
|
|
devtools({
|
|
logging: false,
|
|
eventBusConfig: { enabled: false },
|
|
enhancedLogs: { enabled: false },
|
|
consolePiping: { enabled: false },
|
|
removeDevtoolsOnBuild: false,
|
|
injectSource: { enabled: true },
|
|
}),
|
|
);
|
|
}
|
|
plugins.push(tailwindcss());
|
|
plugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
|
|
plugins.push(
|
|
tanstackStart({
|
|
importProtection: {
|
|
behavior: "error",
|
|
client: { files: ["**/server/**"], specifiers: ["server-only"] },
|
|
},
|
|
// Redirect TanStack Start's bundled server entry to src/server.ts (our SSR error wrapper).
|
|
// nitro/vite builds from this
|
|
server: { entry: "server" },
|
|
}),
|
|
);
|
|
if (command === "build") {
|
|
const { nitro } = await import("nitro/vite");
|
|
plugins.push(nitro({ defaultPreset: "cloudflare-module" }));
|
|
}
|
|
plugins.push(viteReact());
|
|
|
|
let config: UserConfig = {
|
|
define: envDefine,
|
|
...(isDevBuild
|
|
? {
|
|
environments: {
|
|
client: { define: { "process.env.NODE_ENV": JSON.stringify("development") } },
|
|
},
|
|
}
|
|
: {}),
|
|
css: { transformer: "lightningcss" as const },
|
|
resolve: {
|
|
alias: { "@": `${process.cwd()}/src` },
|
|
dedupe: [
|
|
"react",
|
|
"react-dom",
|
|
"react/jsx-runtime",
|
|
"react/jsx-dev-runtime",
|
|
"@tanstack/react-query",
|
|
"@tanstack/query-core",
|
|
],
|
|
},
|
|
optimizeDeps: {
|
|
include: [
|
|
"react",
|
|
"react-dom",
|
|
"react-dom/client",
|
|
"react/jsx-runtime",
|
|
"react/jsx-dev-runtime",
|
|
],
|
|
ignoreOutdatedRequests: true,
|
|
},
|
|
plugins,
|
|
};
|
|
|
|
config = mergeConfig(config, {
|
|
server: {
|
|
host: "::",
|
|
port: 8080,
|
|
watch: { awaitWriteFinish: { stabilityThreshold: 1000, pollInterval: 100 } },
|
|
},
|
|
});
|
|
|
|
return config;
|
|
});
|