Files
nyaterm/vite.config.ts

90 lines
1.9 KiB
TypeScript

import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import browserslist from "browserslist";
import { browserslistToTargets } from "lightningcss";
import { configDefaults } from "vitest/config";
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [react(), tailwindcss()],
base: process.env.NYATERM_WEB_BASE_PATH || "/",
define: {
__APP_VERSION__: JSON.stringify(
process.env.npm_package_version || "1.2.12",
),
},
optimizeDeps: {
entries: ["index.html"],
},
css: {
transformer: "lightningcss",
lightningcss: {
targets: browserslistToTargets(
browserslist("safari >= 14, chrome >= 105"),
),
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
test: {
environment: "jsdom",
setupFiles: "./src/test/setup.ts",
exclude: [
...configDefaults.exclude,
"**/src-tauri/vendor/**",
"**/temp/**",
"**/e2e/**",
],
},
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
ignored: ["**/src-tauri/**", "**/temp/**"],
},
},
build: {
cssMinify: "lightningcss",
rollupOptions: {
output: {
manualChunks: {
react: ["react", "react-dom"],
xterm: [
"@xterm/xterm",
"@xterm/addon-fit",
"@xterm/addon-image",
"@xterm/addon-web-links",
"@xterm/addon-webgl",
"@xterm/addon-search",
],
tauri: ["@tauri-apps/api"],
},
},
},
},
}));