Files

86 lines
2.9 KiB
JavaScript

import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import wasm from 'vite-plugin-wasm';
import tsconfigPaths from 'vite-tsconfig-paths';
import tailwindcss from '@tailwindcss/vite';
// https://vitejs.dev/config/
export default defineConfig(function () { return ({
resolve: {
alias: {
// libsodium-wrappers-sumo ESM entry imports ./libsodium-sumo.mjs which
// lives in the separate libsodium-sumo package
'./libsodium-sumo.mjs': resolve(__dirname, '../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs'),
},
},
plugins: [
react(),
tailwindcss(),
tsconfigPaths({ root: '../..' }),
wasm(),
],
esbuild: {
// Important for wasm plugin
supported: {
'top-level-await': true,
bigint: true,
},
},
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
watch: {
// Exclude output.wav from being watched
ignored: ['**/output.wav'],
},
// headers: {
// 'Cross-Origin-Embedder-Policy': 'require-corp',
// 'Cross-Origin-Opener-Policy': 'cross-origin',
// },
},
// 3. to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
// to access the Tauri environment variables set by the CLI with information about the current target
envPrefix: [
'VITE_',
'TAURI_PLATFORM',
'TAURI_ARCH',
'TAURI_FAMILY',
'TAURI_PLATFORM_VERSION',
'TAURI_PLATFORM_TYPE',
'TAURI_DEBUG',
],
build: {
rollupOptions: {
input: {
index: resolve(__dirname, 'index.html'),
hanzo_node_manager: resolve(__dirname, 'src/windows/hanzo-node-manager/index.html'),
spotlight: resolve(__dirname, 'src/windows/spotlight/index.html'),
coordinator: resolve(__dirname, 'src/windows/coordinator/index.html'),
hanzo_artifacts: resolve(__dirname, 'src/windows/hanzo-artifacts/index.html'),
},
},
},
test: {
watch: false,
setupFiles: './src/test-setup.ts',
globals: true,
cache: { dir: '../../node_modules/.vitest/apps/hanzo-desktop' },
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/libs/hanzo-message-ts',
provider: 'v8',
},
},
worker: {
format: 'es',
},
}); });