-
Notifications
You must be signed in to change notification settings - Fork 38
/
vite.config.js
39 lines (31 loc) · 1.17 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import serveStatic from 'serve-static';
import serveIndex from 'serve-index';
import createBareServer from '@tomphttp/bare-server-node';
import { uvPath } from '@titaniumnetwork-dev/ultraviolet';
import Corrosion from 'corrosion';
const setupProxy = {
name: 'setup-proxy-plugin',
async configureServer(server) {
const bareServer = createBareServer("/bare/");
const corrosion = new Corrosion({
codec: 'xor',
prefix: '/corrosion/',
title: 'Amethyst'
});
server.middlewares.use((req, res, next) => {
if(bareServer.shouldRoute(req)) bareServer.routeRequest(req, res); else next();
});
server.middlewares.use((req, res, next) => {
if(req.url.startsWith(corrosion.prefix)) corrosion.request(req, res); else next();
});
server.middlewares.use('/cdn/', serveStatic('./gsource/'));
server.middlewares.use('/cdn/', serveIndex('./gsource/', { icons: true }));
return () => server.middlewares.use('/uv/', serveStatic(uvPath));
}
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte(), setupProxy],
});