Repository navigation
Expand file tree
/
Copy pathastro.config.ts
More file actions
153 lines (134 loc) · 4.74 KB
/
Copy pathastro.config.ts
File metadata and controls
153 lines (134 loc) · 4.74 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import path from 'path';
import { fileURLToPath } from 'url';
import { defineConfig, fontProviders } from 'astro/config';
import { unified } from '@astrojs/markdown-remark';
import sitemap from '@astrojs/sitemap';
import tailwindcss from '@tailwindcss/vite';
import mdx from '@astrojs/mdx';
import partytown from '@astrojs/partytown';
import icon from 'astro-icon';
import compress from 'astro-compress';
import type { AstroIntegration } from 'astro';
import astrowind from './vendor/integration';
import budouxWbr from './integrations/budoux-wbr';
import { readingTimeRemarkPlugin, responsiveTablesRehypePlugin } from './src/utils/frontmatter';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const hasExternalScripts = false;
const whenExternalScripts = (items: (() => AstroIntegration) | (() => AstroIntegration)[] = []) =>
hasExternalScripts ? (Array.isArray(items) ? items.map((item) => item()) : [items()]) : [];
export default defineConfig({
output: 'static',
// Prefetch links as they enter the viewport for snappier navigations
// (works together with <ClientRouter />, which enables prefetch by default).
prefetch: {
prefetchAll: true,
defaultStrategy: 'viewport',
},
// Native Fonts API: self-hosts + subsets + preloads Inter and generates
// metric-adjusted fallbacks. Injected via <Font /> in Layout.astro and
// consumed through the `--font-inter` CSS variable in CustomStyles.astro.
fonts: [
{
provider: fontProviders.fontsource(),
name: 'Inter',
cssVariable: '--font-inter',
weights: ['100 900'],
styles: ['normal'],
subsets: ['latin'],
fallbacks: [],
},
{
// Google Fonts serves Japanese in ~120 unicode-range slices, so a page only downloads the glyphs it uses.
provider: fontProviders.google(),
name: 'Noto Sans JP',
cssVariable: '--font-noto-jp',
weights: ['400 700'],
styles: ['normal'],
fallbacks: ['sans-serif'],
},
],
integrations: [
sitemap(),
mdx(),
icon({
// Local SVG icons (used as <Icon name="file-name" />) live next to the other assets.
iconDir: 'src/assets/icons',
include: {
tabler: ['*'],
'flat-color-icons': [
'template',
'gallery',
'approval',
'document',
'advertising',
'currency-exchange',
'voice-presentation',
'business-contact',
'database',
],
},
}),
...whenExternalScripts(() =>
partytown({
config: { forward: ['dataLayer.push'] },
})
),
// Must run before compress(): it rewrites the built HTML.
budouxWbr(),
compress({
// csso off on purpose: its parser doesn't understand the media range
// syntax Tailwind v4 emits for breakpoints (`@media (width>=48rem)`) and
// silently drops every one of those blocks — the site then renders as if
// all `md:`/`lg:` classes were missing. lightningcss parses it correctly.
CSS: { csso: false, lightningcss: { minify: true } },
HTML: {
'html-minifier-terser': {
removeAttributeQuotes: false,
},
},
Image: false,
JavaScript: true,
SVG: false,
Logger: 1,
}),
astrowind({
config: './src/config.yaml',
}),
],
image: {
// Astro's default Sharp service handles local images.
//
// Most remote CDN images (Unsplash, Cloudinary, Imgix…) are routed by
// src/components/common/Image.astro through `unpic`, which rewrites the
// URL with CDN-side query parameters and serves it straight from the
// provider — Astro never downloads it, so they don't need to be listed.
//
// `domains` only matters for remote URLs that fall through to Astro's
// native <Image /> (i.e. providers Unpic can't detect, like Pixabay).
// Listed entries are authorized to be processed by Sharp.
// Unsplash is listed so post covers can be rendered as real 1200×626 Open Graph images.
domains: ['cdn.pixabay.com', 'images.unsplash.com'],
// Emit responsive styles for the native <Image layout=…> used by
// src/components/common/Image.astro (local images). Utility classes on
// each usage still win, since these styles use low-specificity selectors.
responsiveStyles: true,
},
markdown: {
processor: unified({
remarkPlugins: [readingTimeRemarkPlugin],
rehypePlugins: [responsiveTablesRehypePlugin],
}),
shikiConfig: {
// Code blocks follow the site theme; see the `.astro-code` rules in tailwind.css.
themes: { light: 'github-light', dark: 'github-dark' },
},
},
vite: {
plugins: [tailwindcss()],
resolve: {
alias: {
'~': path.resolve(__dirname, './src'),
},
},
},
});