-
Notifications
You must be signed in to change notification settings - Fork 91
/
astro.config.mjs
77 lines (74 loc) · 1.95 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
import { defineConfig, passthroughImageService } from "astro/config";
import preact from "@astrojs/preact";
import mdx from "@astrojs/mdx";
import compress from "astro-compress";
import tailwind from "@astrojs/tailwind";
import serviceWorker from "astrojs-service-worker";
// Allow skipping compression step for faster test build times
// DO NOT SKIP COMPRESSION FOR DEPLOYMENT!
const shouldSkipCompress = Boolean(
process.env.SKIP_BUILD_COMPRESS && process.env.SKIP_BUILD_COMPRESS.length > 0,
);
if (shouldSkipCompress) {
console.log("WILL SKIP COMPRESS BUILD STEP");
}
// https://astro.build/config
export default defineConfig({
site: 'https://p5js.org',
integrations: [
preact({
compat: true,
}),
mdx(),
tailwind(),
shouldSkipCompress ? null : compress(),
serviceWorker({
workbox: {
globPatterns: [
"**/*.{css,js,jpg,json,png,svg,ico,woff,woff2}", // Cache all assets accept HTML
],
clientsClaim: true,
runtimeCaching: [
{
urlPattern: ({ url }) => url.pathname.endsWith(".html"), // Caches HTML pages
handler: "CacheFirst", // Tries the cache first, then falls back to network if offline
options: {
cacheName: "html-pages-cache",
expiration: {
maxEntries: 50, // Limits the number of HTML pages cached
maxAgeSeconds: 24 * 60 * 60 * 7, // Cache for 1 week
},
},
},
],
},
}),
],
prefetch: {
defaultStrategy: "viewport",
prefetchAll: true,
},
trailingSlash: "always",
build: {
format: "directory",
},
server: {
watch: {
ignored: ["src/scripts/**/*.ts"],
},
},
vite: {
rollupOptions: {
external: ["/src/scripts/*"],
},
},
image: {
domains: ["openprocessing.org"],
service: passthroughImageService()
},
markdown: {
shikiConfig: {
theme: 'github-light',
},
},
});