test(frontend): load default config to start vite (#12867)
Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>
This commit is contained in:
parent
4535f9b41b
commit
e21cecefa1
|
@ -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: {
|
||||
|
|
Loading…
Reference in a new issue