122 lines
3.2 KiB
TypeScript
122 lines
3.2 KiB
TypeScript
import { lingui as linguiSolidPlugin } from "@lingui-solid/vite-plugin";
|
|
import devtools from "@solid-devtools/transform";
|
|
import { readdirSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { defineConfig } from "vite";
|
|
import babelMacrosPlugin from "vite-plugin-babel-macros";
|
|
import Inspect from "vite-plugin-inspect";
|
|
import { VitePWA } from "vite-plugin-pwa";
|
|
import solidPlugin from "vite-plugin-solid";
|
|
import solidSvg from "vite-plugin-solid-svg";
|
|
|
|
import codegenPlugin from "./codegen.plugin";
|
|
|
|
const base = process.env.BASE_PATH ?? "/";
|
|
|
|
// @ts-expect-error process is a nodejs global
|
|
const host = process.env.TAURI_DEV_HOST;
|
|
|
|
export default defineConfig({
|
|
base,
|
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
|
//
|
|
// 1. prevent Vite from obscuring rust errors
|
|
clearScreen: false,
|
|
plugins: [
|
|
Inspect(),
|
|
devtools(),
|
|
codegenPlugin(),
|
|
babelMacrosPlugin(),
|
|
linguiSolidPlugin(),
|
|
solidPlugin(),
|
|
solidSvg({
|
|
defaultAsComponent: false,
|
|
}),
|
|
VitePWA({
|
|
srcDir: "src",
|
|
registerType: "autoUpdate",
|
|
filename: "serviceWorker.ts",
|
|
strategies: "injectManifest",
|
|
injectManifest: {
|
|
maximumFileSizeToCacheInBytes: 4000000,
|
|
},
|
|
manifest: {
|
|
name: "Stoat",
|
|
short_name: "Stoat",
|
|
description: "User-first open source chat platform.",
|
|
categories: ["communication", "chat", "messaging"],
|
|
start_url: base,
|
|
orientation: "portrait",
|
|
display_override: ["window-controls-overlay"],
|
|
display: "standalone",
|
|
background_color: "#101823",
|
|
theme_color: "#101823",
|
|
icons: [
|
|
{
|
|
src: `${base}assets/web/android-chrome-192x192.png`,
|
|
type: "image/png",
|
|
sizes: "192x192",
|
|
},
|
|
{
|
|
src: `${base}assets/web/android-chrome-512x512.png`,
|
|
type: "image/png",
|
|
sizes: "512x512",
|
|
},
|
|
{
|
|
src: `${base}assets/web/monochrome.svg`,
|
|
type: "image/svg+xml",
|
|
sizes: "48x48 72x72 96x96 128x128 256x256",
|
|
purpose: "monochrome",
|
|
},
|
|
{
|
|
src: `${base}assets/web/masking-512x512.png`,
|
|
type: "image/png",
|
|
sizes: "512x512",
|
|
purpose: "maskable",
|
|
},
|
|
],
|
|
// TODO: take advantage of shortcuts
|
|
},
|
|
}),
|
|
],
|
|
// 2. tauri expects a fixed port, fail if that port is not available
|
|
server: {
|
|
port: 1420,
|
|
strictPort: true,
|
|
host: host || false,
|
|
hmr: host
|
|
? {
|
|
protocol: "ws",
|
|
host,
|
|
port: 1421,
|
|
}
|
|
: undefined,
|
|
watch: {
|
|
// 3. tell Vite to ignore watching `src-tauri`
|
|
ignored: ["**/src-tauri/**"],
|
|
},
|
|
},
|
|
build: {
|
|
target: "esnext",
|
|
rollupOptions: {
|
|
external: ["hast"],
|
|
},
|
|
sourcemap: true,
|
|
},
|
|
optimizeDeps: {
|
|
exclude: ["hast"],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"styled-system": resolve(__dirname, "styled-system"),
|
|
...readdirSync(resolve(__dirname, "components")).reduce(
|
|
(p, f) => ({
|
|
...p,
|
|
[`@revolt/${f}`]: resolve(__dirname, "components", f),
|
|
}),
|
|
{},
|
|
),
|
|
},
|
|
},
|
|
});
|