forked from PlayForm/Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.ts
126 lines (124 loc) · 2.87 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { defineConfig, envField } from "astro/config";
export const On = process.env["NODE_ENV"] === "development";
export default (await import("astro/config")).defineConfig({
env: {
schema: {
TOKEN_GITHUB_COMMIT: envField.string({
context: "server",
access: "secret",
optional: false,
default: "GitHub Token API Stream",
}),
},
validateSecrets: true,
},
srcDir: "./Source",
publicDir: "./Public",
outDir: "./Target",
site: On ? "HTTP://localhost" : "HTTPS://Status.Editor.Land",
compressHTML: !On,
prefetch: {
defaultStrategy: "hover",
prefetchAll: true,
},
server: {
port: 9999,
},
build: {
concurrency: 9999,
},
integrations: [
(await import("@astrojs/solid-js")).default({
// @ts-ignore
devtools: On,
}),
// @ts-ignore
import.meta.env.MODE === "production"
? (await import("astrojs-service-worker")).default()
: null,
(await import("@astrojs/sitemap")).default(),
!On ? (await import("@playform/inline")).default({ Logger: 1 }) : null,
!On ? (await import("@playform/format")).default({ Logger: 1 }) : null,
!On
? (await import("@playform/compress")).default({ Logger: 1 })
: null,
],
experimental: {
clientPrerender: true,
contentIntellisense: true,
},
vite: {
build: {
sourcemap: On,
manifest: true,
minify: On ? false : "terser",
cssMinify: On ? false : "esbuild",
terserOptions: On
? {
compress: false,
ecma: 2020,
enclose: false,
format: {
ascii_only: false,
braces: false,
comments: false,
ie8: false,
indent_level: 4,
indent_start: 0,
inline_script: false,
keep_numbers: true,
keep_quoted_props: true,
max_line_len: 80,
preamble: null,
ecma: 5,
preserve_annotations: true,
quote_keys: false,
quote_style: 3,
safari10: true,
semicolons: true,
shebang: false,
shorthand: false,
webkit: true,
wrap_func_args: true,
wrap_iife: true,
},
sourceMap: true,
ie8: true,
keep_classnames: true,
keep_fnames: true,
mangle: false,
module: true,
toplevel: true,
}
: {},
},
resolve: {
preserveSymlinks: true,
},
css: {
devSourcemap: On,
transformer: "postcss",
},
plugins: [
{
name: "crossorigin",
transform(code, id, options) {
return code
.replace(/<script/g, '<script crossorigin="anonymous"')
.replace(
/<link[^>]*(?=.*rel="preload")(?=.*href="[^"]*\.js")(?=.*as="script")[^>]*/g,
'$& crossorigin="anonymous"',
)
.replace(
/<link[^>]*(?=.*rel="preload")(?=.*as="font")[^>]*/g,
'$& crossorigin="anonymous"',
)
.replace(
/<link[^>]*(?=.*rel="stylesheet")(?=.*href="https?:\/\/[^"]*")[^>]*/g,
'$& crossorigin="anonymous"',
);
},
},
],
},
}) as typeof defineConfig;