test(frontend): load default config to start vite

This commit is contained in:
Kagami Sascha Rosylight 2023-12-31 14:49:14 +01:00
parent 379079ee42
commit ddfcdd3335
1 changed files with 20 additions and 13 deletions

View File

@ -1,5 +1,7 @@
import dns from 'dns';
import { readFile } from 'node:fs/promises';
import { defineConfig } from 'vite';
import * as yaml from 'js-yaml';
import locales from '../../locales/index.js';
import { getConfig } from './vite.config.js';
@ -7,6 +9,11 @@ dns.setDefaultResultOrder('ipv4first');
const defaultConfig = getConfig();
const { port } = yaml.load(await readFile('../../.config/default.yml', 'utf-8'));
const httpUrl = `http://localhost:${port}/`;
const websocketUrl = `ws://localhost:${port}/`;
const devConfig = {
// 基本の設定は vite.config.js から引き継ぐ
...defaultConfig,
@ -19,28 +26,28 @@ const devConfig = {
proxy: {
'/api': {
changeOrigin: true,
target: 'http://localhost:3000/',
target: httpUrl,
},
'/assets': 'http://localhost:3000/',
'/static-assets': 'http://localhost:3000/',
'/client-assets': 'http://localhost:3000/',
'/files': 'http://localhost:3000/',
'/twemoji': 'http://localhost:3000/',
'/fluent-emoji': 'http://localhost:3000/',
'/sw.js': 'http://localhost:3000/',
'/assets': httpUrl,
'/static-assets': httpUrl,
'/client-assets': httpUrl,
'/files': httpUrl,
'/twemoji': httpUrl,
'/fluent-emoji': httpUrl,
'/sw.js': httpUrl,
'/streaming': {
target: 'ws://localhost:3000/',
target: websocketUrl,
ws: true,
},
'/favicon.ico': 'http://localhost:3000/',
'/favicon.ico': httpUrl,
'/identicon': {
target: 'http://localhost:3000/',
target: httpUrl,
rewrite(path) {
return path.replace('@localhost:5173', '');
},
},
'/url': 'http://localhost:3000',
'/proxy': 'http://localhost:3000',
'/url': httpUrl,
'/proxy': httpUrl,
},
},
build: {