File size: 3,345 Bytes
46c7a16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import sitemap from '@astrojs/sitemap';
import tailwind from '@astrojs/tailwind';
import { baremuxPath } from '@mercuryworkshop/bare-mux/node';
//@ts-expect-error No types
import { epoxyPath } from '@mercuryworkshop/epoxy-transport';
import { libcurlPath } from '@mercuryworkshop/libcurl-transport';
import playformCompress from '@playform/compress';
import { uvPath } from '@titaniumnetwork-dev/ultraviolet';
import icon from 'astro-icon';
import robotsTxt from 'astro-robots-txt';
import { defineConfig, envField } from 'astro/config';
import { viteStaticCopy } from 'vite-plugin-static-copy';
//we need the buildOpts from here : D
import { parsedDoc } from './server/config/config.ts';
const scramjetPath = `${import.meta.dirname}/vendor/scramjet/dist/`

// https://astro.build/config
export default defineConfig({
    site: Deno.env.get('SITE') || 'https://localhost:8080',
    integrations: [
        tailwind(),
        robotsTxt(),
        sitemap(),
        icon(),
        playformCompress({
            CSS: false,
            HTML: true,
            Image: true,
            JavaScript: true,
            SVG: true,
        }),
    ],
    output: 'static',
    env: {
        schema: {
            GAMES_LINK: envField.boolean({
                context: 'client',
                access: 'public',
                default: parsedDoc.buildOpts.games,
            }),
            SEO: envField.boolean({
                context: 'client',
                access: 'public',
                default: Boolean(Deno.env.get('SEO')) || parsedDoc.seo.enabled
            })
        },
    },
    vite: {
        plugins: [
            viteStaticCopy({
                targets: [
                    {
                        src: `${uvPath}/**/*`.replace(/\\/g, '/'),
                        dest: 'uv',
                        overwrite: false,
                    },
                    {
                        src: `${epoxyPath}/**/*`.replace(/\\/g, '/'),
                        dest: 'epoxy',
                        overwrite: false,
                    },
                    {
                        src: `${libcurlPath}/**/*`.replace(/\\/g, '/'),
                        dest: 'libcurl',
                        overwrite: false,
                    },
                    {
                        src: `${baremuxPath}/**/*`.replace(/\\/g, '/'),
                        dest: 'baremux',
                        overwrite: false,
                    },
                    {
                        src: `${scramjetPath}/**/*`.replace(/\\/g, '/'),
                        dest: 'scram',
                        overwrite: false
                    }
                ],
            }),
        ],
        server: {
            proxy: {
                '/wisp/': {
                    target: 'wss://ruby.rubynetwork.co/wisp/',
                    changeOrigin: true,
                    ws: true,
                    rewrite: (path) => path.replace(/^\/wisp\//, ''),
                },
                '/gms/': {
                    target: 'https://rawcdn.githack.com/ruby-network/ruby-assets/main/',
                    changeOrigin: true,
                    ws: true,
                    secure: false,
                    rewrite: (path) => path.replace(/^\/gms\//, ''),
                },
            },
        },
    },
});