import {readFileSync} from 'node:fs' import {resolve} from 'node:path' import {fileURLToPath, URL} from 'node:url' import Vue from '@vitejs/plugin-vue' import Fonts from 'unplugin-fonts/vite' import {defineConfig} from 'vite' import Vuetify, {transformAssetUrls} from 'vite-plugin-vuetify' import {parse} from 'smol-toml' const projectRoot = fileURLToPath(new URL('..', import.meta.url)) const config = parse(readFileSync(resolve(projectRoot, 'config.toml'), 'utf8')) const network = config.network as {tcp_port: number, tls?: {cert_path: string, key_path: string}} const tls = network.tls const https = tls ? { cert: readFileSync(resolve(projectRoot, tls.cert_path)), key: readFileSync(resolve(projectRoot, tls.key_path)), } : undefined const target = `${tls ? 'https' : 'http'}://localhost:${network.tcp_port}` // https://vitejs.dev/config/ export default defineConfig({ plugins: [ Vue({ template: {transformAssetUrls}, }), // https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme Vuetify({ autoImport: true, styles: { configFile: 'src/styles/settings.scss', }, }), Fonts({ fontsource: { families: [ { name: 'Roboto', weights: [100, 300, 400, 500, 700, 900], styles: ['normal', 'italic'], }, ], }, }), ], define: {'process.env': {}}, resolve: { alias: { '@': fileURLToPath(new URL('src', import.meta.url)), }, extensions: [ '.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue', ], }, server: { port: 3000, host: '0.0.0.0', https, allowedHosts: ["goesseau.eu"], proxy: { '/api': { target, changeOrigin: true, secure: !tls, }, '/ws': { target, ws: true, secure: !tls, }, }, }, })