-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathastro.config.ts
78 lines (77 loc) · 2.09 KB
/
astro.config.ts
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
import { execSync } from 'child_process';
import node from '@astrojs/node';
import tailwind from '@astrojs/tailwind';
import { baremuxPath } from '@mercuryworkshop/bare-mux/node';
import { epoxyPath } from '@mercuryworkshop/epoxy-transport';
import { scramjetPath } from '@mercuryworkshop/scramjet';
import { server as wisp } from '@mercuryworkshop/wisp-js/server';
import playformCompress from '@playform/compress';
import { defineConfig } from 'astro/config';
import { normalizePath } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { version } from './package.json';
function check() {
try {
return execSync('git log -1 --format=%cd', { stdio: 'pipe' })
.toString()
.trim();
} catch {
return new Date().toISOString();
}
}
export default defineConfig({
output: 'server',
adapter: node({ mode: 'middleware' }),
integrations: [
tailwind(),
playformCompress({
CSS: false,
HTML: true,
Image: true,
JavaScript: true,
SVG: true,
}),
],
prefetch: {
prefetchAll: true,
defaultStrategy: 'load',
},
vite: {
define: {
VERSION: JSON.stringify(version),
LAST_UPDATED: JSON.stringify(check()),
},
plugins: [
{
name: 'viteserver',
configureServer(server) {
server.httpServer?.on('upgrade', (req, socket, head) => {
if (req.url?.startsWith('/wsp/')) {
wisp.routeRequest(req, socket, head);
}
});
},
},
viteStaticCopy({
targets: [
{
src: normalizePath(epoxyPath + '/**/*.mjs'),
dest: 'assets/packaged/ep',
overwrite: false,
},
{
src: normalizePath(baremuxPath + '/**/*.js'),
dest: 'assets/packaged/bm',
overwrite: false,
},
{
src: `${scramjetPath}/**/*.js`.replace(/\\/g, '/'),
dest: 'assets/packaged/scram',
overwrite: false,
rename: (name) => `${name.replace('scramjet.', '')}.js`,
},
],
}),
],
},
});