Files
youtube-generator/vite.config.ts
T
poli0981andClaude Opus 5.5 ad523ea0fb chore(typescript): move to TypeScript 7 with an ES2025 target
TypeScript 7.0 is the native compiler and ships no JavaScript API, which
typescript-eslint still needs. Install both, as Microsoft documents it:
- "@typescript/native": "npm:typescript@^7.0.2" gives `tsc` = 7.0
- "typescript": "npm:@typescript/typescript6@^6.0.2" gives the 6.0 API
  that typescript-eslint loads (its peer range stops below 6.1), and `tsc6`
CI fails if `tsc` ever resolves to TypeScript 6 (@typescript/old, pulled in
by the 6.0 package, ships a `tsc` too).

tsconfig.json (src):
- target ES2025: the newest year TypeScript 7.0, esbuild and Vite all know
- lib ES2022 + DOM: the browser floor (Vite's baseline-widely-available,
  Chrome 111 / Safari 16.4 / Firefox 114), because nothing polyfills
- baseUrl removed (gone in 7.0; paths were already relative), DOM.Iterable
  dropped (merged into DOM), `types: []` spelled out, erasableSyntaxOnly and
  verbatimModuleSyntax on (both clean)
tsconfig.check.json: lib ES2025 for tests, scripts, worker and build plugins.

Platform floor: the Tauri build no longer lowers to es2020; it shares the
web build's baseline (the stylesheet already needed Chromium 99+ /
Safari 15.4+). macOS minimumSystemVersion is 11.0 (the build is arm64).

Also: eslint.config.js uses ESLint's defineConfig (tseslint.config is
deprecated); THIRD_PARTY_NOTICES names the real package behind an npm
alias, sorted with a shared code-unit comparator (src/utils/sort.ts);
Dependabot groups typescript + @typescript/*; a test's typed-array
annotation follows TypeScript 7's lib.dom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:48:21 +07:00

77 lines
3.5 KiB
TypeScript

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import { legalDocsPlugin } from "./build-plugins/legal-docs.ts";
import { cloudflareWebAnalytics, securityTxt } from "./build-plugins/web-only.ts";
const isTauri = !!process.env.TAURI_ENV_PLATFORM;
export default defineConfig({
plugins: [
react(),
// In-app Legal Center content for every build; the static /legal pages,
// security.txt and the analytics beacon only for the web deployment.
legalDocsPlugin({ emitStaticPages: !isTauri }),
...(isTauri ? [] : [securityTxt(), cloudflareWebAnalytics()]),
],
// Both builds are served from the root: the web build from
// https://ytgenerator.stream (Cloudflare Workers static assets, see
// wrangler.jsonc) and the Tauri build from its own asset protocol. The old
// GitHub Pages sub-path `/youtube-generator/` is gone as of v1.0.0.
base: "/",
resolve: {
alias: {
"@": path.resolve(import.meta.dirname, "./src"),
"@config": path.resolve(import.meta.dirname, "./src/config"),
"@engine": path.resolve(import.meta.dirname, "./src/engine"),
"@store": path.resolve(import.meta.dirname, "./src/store"),
"@hooks": path.resolve(import.meta.dirname, "./src/hooks"),
"@components": path.resolve(import.meta.dirname, "./src/components"),
"@pages": path.resolve(import.meta.dirname, "./src/pages"),
"@utils": path.resolve(import.meta.dirname, "./src/utils"),
"@i18n": path.resolve(import.meta.dirname, "./src/i18n"),
},
},
server: {
// `tauri dev` loads this server while cargo rewrites files under
// src-tauri/target, and watching those crashed Vite on Windows (EBUSY on
// the locked .dll). Nothing under src-tauri or .wrangler is part of the
// web app.
watch: { ignored: ["**/src-tauri/**", "**/.wrangler/**"] },
},
build: {
// No `target`: the web and Tauri builds share Vite's default,
// `baseline-widely-available` (Chrome 111, Safari 16.4, Firefox 114), which
// is also the floor tsconfig.json's `lib` holds the app to. Tauri builds
// used to be lowered to es2020 for frozen ~91 Android System WebViews, but
// the stylesheet's cascade layers already need Chromium 99+ / Safari 15.4+,
// so such a WebView rendered the app unstyled either way.
//
// Never inline assets as data: URIs — the Tauri CSP only allows 'self'
// for images and fonts, so an inlined icon would silently fail there.
assetsInlineLimit: 0,
// The full license text of every bundled package, for the "Third-party
// notices" page to link to (Apache-2.0 / MIT / ISC all ask for it).
license: { fileName: "licenses/third-party.md" },
rollupOptions: {
output: {
// Vite 8 bundles with Rolldown, which only accepts the function form of
// manualChunks (the object form is a Rollup-only API). Anchored [\\/]
// regexes keep each vendor in its own chunk without cross-matching —
// react-router* and react-i18next must not fall into the "react" chunk.
manualChunks(id) {
if (/[\\/]node_modules[\\/]react(-dom)?[\\/]/.test(id)) return "react";
if (/[\\/]node_modules[\\/]react-router(-dom)?[\\/]/.test(id)) return "router";
if (
/[\\/]node_modules[\\/](i18next|react-i18next|i18next-resources-to-backend)[\\/]/.test(
id,
)
)
return "i18n";
return undefined;
},
},
},
},
});