-
Notifications
You must be signed in to change notification settings - Fork 6
/
astro.config.mjs
84 lines (78 loc) · 2.22 KB
/
astro.config.mjs
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
import { config } from 'dotenv'
import { defineConfig } from 'astro/config'
import clubs from '@devprotocol/clubs-core'
import vercel from '@astrojs/vercel/serverless'
import tailwind from '@astrojs/tailwind'
import lit from '@astrojs/lit'
import vue from '@astrojs/vue'
import react from '@astrojs/react'
import svelte from '@astrojs/svelte'
// import commonjs from '@rollup/plugin-commonjs'
import builtInApiPaths from './built-in-api-paths'
config()
const singleMode = ((i) => (i > -1 ? process.argv[i + 1] : undefined))(
process.argv.findIndex((a) => a === '--club'),
)
// https://astro.build/config
export default defineConfig({
site: process.env.PUBLIC_SITE_URL,
server: {
port: 3000,
},
output: 'server',
adapter: vercel(),
integrations: [
clubs(),
{
name: 'clubs:multi-tenant',
hooks: {
'astro:server:setup': ({ server }) => {
server.middlewares.use((req, _, next) => {
if (
req.headers.accept?.includes('text/html') ||
(req.url.startsWith('/api/') &&
builtInApiPaths.every((p) => !req.url.startsWith(p)))
) {
const host = req.headers.host.split('.')
if (host.length > 1 || singleMode) {
req.url = `/sites_/${singleMode ?? host[0]}${req.url}`
}
}
next()
})
},
},
},
lit(),
vue(),
react(),
tailwind({ applyBaseStyles: false }),
svelte(),
],
vite: {
ssr: { noExternal: ['path-to-regexp'] },
build: { sourcemap: true },
plugins: [
// commonjs({
// requireReturnsDefault: (id) => {
// return id.includes('qrcode')
// },
// }),
],
server: {
hmr: {
timeout: 360000,
},
},
resolve: {
alias: {
'three/examples/jsm/controls/OrbitControls':
'/node_modules/three/examples/jsm/controls/OrbitControls',
'@crossmint/client-sdk-react-ui/package.json':
'/node_modules/@crossmint/client-sdk-react-ui/package.json',
// TODO: workaround for until closed this -> https://github.com/eemeli/yaml/pull/560
// yaml: '/node_modules/yaml/browser/index.js',
},
},
},
})