-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathastro.config.ts
More file actions
119 lines (115 loc) · 2.87 KB
/
astro.config.ts
File metadata and controls
119 lines (115 loc) · 2.87 KB
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
import markdoc from '@astrojs/markdoc';
import sitemap from '@astrojs/sitemap';
import playformCompress from '@playform/compress';
import betterImageService from 'astro-better-image-service';
import robotsTxt from 'astro-robots-txt';
import { defineConfig, fontProviders } from 'astro/config';
import {
ASTRO_SNAPSHOT_CONFIG,
I18N_CONFIG,
} from './src/config-transformer.ts';
import snapshot from '@twocaretcat/astro-snapshot';
import { FONTS } from './src/config/fonts.ts';
import { SITE } from './src/config/site.ts';
import { SOCIAL_PREVIEW } from './src/config/social-preview.ts';
// https://astro.build/config
export default defineConfig({
site: SITE.url.base,
base: SITE.basePath,
srcDir: SITE.srcDir,
output: 'static',
trailingSlash: 'never',
server: {
host: true,
},
build: {
assets: 'assets',
format: 'file',
},
prefetch: {
prefetchAll: true,
defaultStrategy: 'hover',
},
image: {
remotePatterns: [{ protocol: 'https' }],
responsiveStyles: true,
layout: 'constrained',
},
i18n: I18N_CONFIG.astro,
experimental: {
svgo: true,
fonts: FONTS.map((props) => ({
...props,
provider: fontProviders.fontsource(),
})),
},
integrations: [
betterImageService({
sharp: {
webp: {
effort: 6,
// Webp has some pretty awful banding on gradients in social preview images regardless of the quality setting, so we use near-lossless mode to prevent this
nearLossless: true,
},
avif: {
quality: 60,
effort: 9,
},
png: {
compressionLevel: 9,
},
},
}),
// TODO: Create a custom Sup component so we don't need to allow HTML
markdoc({ allowHTML: true }),
robotsTxt({
sitemapBaseFileName: `${SITE.sitemapPrefix}-index`,
}),
sitemap({
filenameBase: SITE.sitemapPrefix,
changefreq: 'monthly',
lastmod: new Date(),
i18n: I18N_CONFIG.sitemap,
serialize(item) {
const path = new URL(item.url).pathname;
// Don't include social preview pages in the sitemap
if (path.includes(`/${SOCIAL_PREVIEW.id}`)) {
return undefined;
}
// The homepage automatically redirects to the default locale, add the x-default hreflang tag
if (item.links) {
for (const link of item?.links) {
if (link.url === `${SITE.url.base}${SITE.basePath}`) {
link.lang = 'x-default';
}
}
}
return item;
},
}),
snapshot(ASTRO_SNAPSHOT_CONFIG),
// Workaround for https://github.com/withastro/prettier-plugin-astro/issues/308
playformCompress({
HTML: {
'html-minifier-terser': {
minifyCSS: false,
},
},
CSS: {
csso: false,
lightningcss: {
minify: true,
},
},
Image: false,
SVG: false,
}),
],
vite: {
optimizeDeps: {
// The WASM module isn't included in the pre-bundled output for some reason
// This breaks text linting in dev builds, so we disable optimization for the whole library
exclude: ['harper.js'],
},
},
});