-
Notifications
You must be signed in to change notification settings - Fork 6
/
astro.config.ts
112 lines (108 loc) · 2.79 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
import sitemap from '@astrojs/sitemap';
import {
transformerMetaHighlight,
transformerMetaWordHighlight,
transformerNotationDiff,
transformerNotationErrorLevel,
transformerNotationFocus,
transformerNotationHighlight,
transformerNotationWordHighlight,
transformerRenderWhitespace
} from '@shikijs/transformers';
import { transformerTwoslash } from '@shikijs/twoslash';
import astroPWA, { type PwaOptions } from '@vite-pwa/astro';
import astroIcon from 'astro-icon';
import { defineConfig } from 'astro/config';
import { readFileSync } from 'node:fs';
import { assetsCache, externalResourcesCache, pagesCache, scriptsCache } from './src/sw-caching.js';
import hcShikiTheme from './src/styles/hc-shiki-theme.json';
const manifest: PwaOptions['manifest'] = JSON.parse(readFileSync('./src/manifest.json', {
encoding: 'utf8'
}));
const mode = process.env['NODE_ENV'] === 'production' ? 'production' : 'development';
// https://astro.build/config
export default defineConfig({
devToolbar: {
enabled: false
},
site: 'https://blog.torontojs.com',
base: '/',
trailingSlash: 'ignore',
compressHTML: true,
build: {
format: 'directory'
},
server: {
host: 'localhost',
port: 3000
},
...(mode !== 'production' && {
vite: {
server: {
https: {
cert: './certs/server.crt',
key: './certs/server.key'
}
}
}
}),
markdown: {
syntaxHighlight: 'shiki',
shikiConfig: {
theme: 'css-variables',
themes: {
light: 'one-light',
dark: 'ayu-dark',
// @ts-expect-error - Astro is fussy about custom theme
contrast: hcShikiTheme
},
defaultColor: false,
wrap: true,
transformers: [
transformerTwoslash({
explicitTrigger: true,
rendererRich: { errorRendering: 'hover' }
}),
transformerNotationDiff(),
transformerNotationHighlight(),
transformerNotationWordHighlight(),
transformerNotationFocus(),
transformerNotationErrorLevel(),
transformerRenderWhitespace({ position: 'boundary' }),
transformerMetaHighlight(),
transformerMetaWordHighlight()
]
},
},
integrations: [
astroPWA({
registerType: 'prompt',
minify: true,
includeAssets: ['/icons/icon.svg'],
manifest,
workbox: {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
maximumFileSizeToCacheInBytes: 1024 * 128,
cleanupOutdatedCaches: true,
clientsClaim: true,
skipWaiting: false,
navigateFallback: '/offline',
navigateFallbackDenylist: [/\.(?:png|gif|jpg|jpeg|webp|svg|ico)$/iu],
directoryIndex: 'index.html',
runtimeCaching: [externalResourcesCache, assetsCache, scriptsCache, pagesCache]
},
selfDestroying: true,
devOptions: {
enabled: false
}
}),
sitemap({
changefreq: 'weekly',
priority: 0.7,
lastmod: new Date()
}),
astroIcon({
iconDir: 'src/assets/icons'
})
]
});