-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathastro.config.mjs
158 lines (155 loc) · 4.46 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
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
154
155
156
157
158
import mdx from "@astrojs/mdx";
import solidJs from '@astrojs/solid-js';
import sitemap from "@astrojs/sitemap";
import tailwind from "@astrojs/tailwind";
import expressiveCode from "astro-expressive-code";
import { defineConfig, envField } from "astro/config";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeKatex from "rehype-katex";
import rehypeSlug from "rehype-slug";
import rehypeWrap from "rehype-wrap-all";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import compress from "@playform/compress"
import criticalCSS from "astro-critical-css";
import { imageService } from "@unpic/astro/service";
import { visualizer } from "rollup-plugin-visualizer";
import rehypeReplaceStrings from "./src/lib/plugins/rehypeStringReplace.js";
import tailwindcss from 'tailwindcss'
import tailwindcssNesting from 'tailwindcss/nesting'
import autoprefixer from 'autoprefixer'
import postcssImporter from 'postcss-import';
const DEFAULT_SITE_URL = "http://localhost:4321"
// https://astro.build/config
export default defineConfig({
cacheDir: ".cache",
site: process.env.SITE_URL ?? DEFAULT_SITE_URL,
env: {
schema: {
ALGOLIA_APP_ID: envField.string({
context: "client",
access: "public",
default: "VJ9GF38NJX"
}),
ALGOLIA_SEARCH_API_KEY: envField.string({
context: "client",
access: "public",
default: "76e7c17dae4d35f581c858ee2784b41a" // Don't worry, this is a public key used be the FE to hit the search API
}),
ALGOLIA_INDEX_NAME: envField.string({
context: "client",
access: "public",
default: "docs-2"
}),
SITE_URL: envField.string({
context: "client",
access: "public",
default: DEFAULT_SITE_URL
}),
NODE_ENV: envField.enum({
context: "client",
access: "public",
default: "development",
values: ["development", "production"]
})
}
},
prefetch: {
defaultStrategy: 'hover'
},
build: {
inlineStylesheets: 'never' // We use the criticalcss plugin for this
},
image: {
service: imageService({
placeholder: "blurhash",
})
},
integrations: [
solidJs(),
tailwind({ applyBaseStyles: false }),
expressiveCode({
shiki: {
bundledLangs: [
'shellsession',
'nix',
'hcl',
'yaml',
'dockerfile',
'dotenv'
]
}
}),
mdx(),
sitemap(),
criticalCSS({
dimensions: [
{width: 624, height: 900 },
{width: 765, height: 900 },
{width: 1023, height: 1500 },
{width: 1263, height: 2000 },
{width: 1500, height: 2000 }
],
strict: true,
inline: {
// The actual default is "swap" which appears to not work will with astro view transitions
// as the stylesheets end up above the inlined styles which breaks styling in some circumstances (the external stylesheets
// should have priority and thus must come AFTER the inlined styles). The "default" strategy adds
// the external stylesheets to the end of the body which ensures they come after the inlined styles regardless of
// the shenanigans that astro does to the <head>
strategy: "default"
}
}),
compress({
HTML: {
"html-minifier-terser": {
minifyCSS: true,
minifyJS: true,
removeComments: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
sortClassName: true,
sortAttributes: true
}
},
Image: false // Image compression is tackled by the image service
})
],
markdown: {
remarkPlugins: [remarkGfm, remarkMath],
rehypePlugins: [
rehypeReplaceStrings,
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: "append" }],
[
rehypeWrap,
{ selector: "table", wrapper: "div.overflow-x-scroll mb-4" },
],
rehypeKatex,
],
shikiConfig: {
wrap: false,
},
},
experimental: {
svg: {
mode: 'inline'
}
},
vite: {
plugins: [visualizer({
emitFile: true,
filename: "stats.html"
})],
css: {
// For some reason, both this AND the postcss.config.cjs file are required. No idea why.
// Be sure to keep them in sync.
plugins: [
postcssImporter(),
tailwindcssNesting(),
tailwindcss(),
autoprefixer(),
]
}
}
});