57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
const beocreateHost = env.VITE_BEOCREATE_HOST || '192.168.178.78';
|
|
const beocreatePort = env.VITE_BEOCREATE_PORT || '13141';
|
|
|
|
return {
|
|
plugins: [react()],
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true,
|
|
},
|
|
// Dev proxy — mirrors the Nginx config so `npm run dev` works too
|
|
server: {
|
|
proxy: {
|
|
'/api/hifiberry': {
|
|
target: `http://${beocreateHost}:${beocreatePort}`,
|
|
rewrite: path => path.replace(/^\/api\/hifiberry/, ''),
|
|
changeOrigin: true,
|
|
},
|
|
'/api/mopidy': {
|
|
target: 'http://localhost:6680',
|
|
rewrite: path => path.replace(/^\/api\/mopidy/, '/mopidy'),
|
|
changeOrigin: true,
|
|
},
|
|
'/api/mopidy-image': {
|
|
target: 'http://localhost:6680',
|
|
rewrite: path => path.replace(/^\/api\/mopidy-image/, ''),
|
|
changeOrigin: true,
|
|
},
|
|
'/ws/mopidy': {
|
|
target: 'ws://localhost:6680',
|
|
rewrite: path => '/mopidy/ws',
|
|
ws: true,
|
|
},
|
|
'/ws/snapcast': {
|
|
target: 'ws://localhost:1780',
|
|
rewrite: () => '/jsonrpc',
|
|
ws: true,
|
|
},
|
|
'/api/snapcast/rpc': {
|
|
target: 'http://localhost:1780',
|
|
rewrite: () => '/jsonrpc',
|
|
changeOrigin: true,
|
|
},
|
|
'/api/now-playing': {
|
|
target: 'http://localhost:8090',
|
|
rewrite: path => path.replace(/^\/api\/now-playing/, ''),
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|