Initial commit
This commit is contained in:
1 parent
1ba45f88aa
commit
9e6804c1ab
77 files changed
+3888
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { defineConfig } from 'astro/config';
|
||||
import sitemap from '@astrojs/sitemap';
|
||||
import { readdirSync, readFileSync, rmSync, statSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { join } from 'node:path';
|
||||
|
||||
// Astro emits every imported screenshot at full size even when pages only use the optimised
|
||||
// WebP variants. Drop originals nothing links to, so a deploy isn't ~17 MB heavier than needed.
|
||||
function pruneUnusedOriginals() {
|
||||
return {
|
||||
name: 'prune-unused-originals',
|
||||
hooks: {
|
||||
'astro:build:done': ({ dir }) => {
|
||||
const root = fileURLToPath(dir);
|
||||
const files = [];
|
||||
const walk = (d) => {
|
||||
for (const n of readdirSync(d)) {
|
||||
const p = join(d, n);
|
||||
statSync(p).isDirectory() ? walk(p) : files.push(p);
|
||||
}
|
||||
};
|
||||
walk(root);
|
||||
const text = files
|
||||
.filter((f) => /\.(html|css|js|xml|json|webmanifest)$/.test(f))
|
||||
.map((f) => readFileSync(f, 'utf8'))
|
||||
.join('\n');
|
||||
for (const f of files) {
|
||||
if (!/_astro[\\/][^\\/]+\.(png|jpe?g)$/.test(f)) continue;
|
||||
const name = f.split(/[\\/]/).pop();
|
||||
if (!text.includes(name)) rmSync(f);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// SITE_URL / BASE_PATH let CI set these without editing the file
|
||||
// (e.g. a GitHub Pages project site: https://user.github.io + /ink-website).
|
||||
export default defineConfig({
|
||||
site: process.env.SITE_URL ?? 'https://ink.example',
|
||||
base: process.env.BASE_PATH ?? '/',
|
||||
output: 'static',
|
||||
trailingSlash: 'always',
|
||||
integrations: [sitemap(), pruneUnusedOriginals()],
|
||||
build: { inlineStylesheets: 'auto' },
|
||||
// lightningcss merges `backdrop-filter` + `-webkit-backdrop-filter` into the prefixed one only,
|
||||
// which Chrome and Firefox ignore (no blur). esbuild leaves both declarations alone.
|
||||
vite: { build: { cssMinify: 'esbuild' } },
|
||||
devToolbar: { enabled: false },
|
||||
});
|
||||
Reference in new issue
Block a user