-
Notifications
You must be signed in to change notification settings - Fork 2
/
astro.config.js
56 lines (51 loc) · 1.45 KB
/
astro.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-check
import { defineConfig } from 'astro/config'
import deno from '@astrojs/deno'
import mdx from '@astrojs/mdx'
import node from '@astrojs/node'
import preact from '@astrojs/preact'
import sitemap from '@astrojs/sitemap'
import vercel from '@astrojs/vercel/serverless'
import fs from 'node:fs'
import { deflate } from 'pako'
const isDeno = process.argv.includes('--deno')
const isNode = !isDeno && process.argv.includes('--node')
const isVercel = !isDeno && !isNode
/** @type {import('vite').Plugin} */
const uint8ArrayLoader = {
name: 'uint8Array-loader',
transform(_code, id) {
const [path, query] = id.split('?')
if (query !== 'uint8array') return null
const data = fs.readFileSync(path)
const hex = deflate(new Uint8Array(data), { level: 9 }).reduce(
(chars, number) => chars + number.toString(16).padStart(2, '0'),
''
)
return `import { inflate } from 'pako';
const hex = '${hex}';
const array = new Uint8Array(${hex.length / 2});
for (let i = 0, j = 0; i < ${hex.length / 2}; i++, j+=2) {
array[i] = parseInt(hex.slice(j, j + 2), 16);
}
export default inflate(array);`
},
}
export default defineConfig({
adapter: (isDeno && deno()) || (isNode && node({ mode: 'standalone' })) || vercel(),
integrations: [
preact(),
mdx(),
sitemap({
filter: (page) => !page.includes('rss.xml'),
}),
],
output: 'server',
site: 'https://settlers2.net',
vite: {
optimizeDeps: {
exclude: ['postgres'],
},
plugins: [uint8ArrayLoader],
},
})