|
| 1 | +import rehypeExternalLinks from 'rehype-external-links' |
| 2 | +import { browserslistToTargets } from 'lightningcss' |
| 3 | +import svelteSvg from '@poppanator/sveltekit-svg' |
| 4 | +import remarkSectionize from 'remark-sectionize' |
| 5 | +import { defineConfig } from 'astro/config' |
| 6 | +import compress from '@playform/compress' |
| 7 | +import { fileURLToPath } from 'node:url' |
| 8 | +import browserslist from 'browserslist' |
| 9 | +import sitemap from '@astrojs/sitemap' |
| 10 | +import svelte from '@astrojs/svelte' |
| 11 | +import mdx from '@astrojs/mdx' |
| 12 | +import path from 'node:path' |
| 13 | + |
| 14 | +import { remarkHeadings } from './docs/plugins/remark-headings' |
| 15 | +import { colorTheme } from './docs/utils/shiki-theme' |
| 16 | + |
| 17 | +let dirname = fileURLToPath(path.dirname(import.meta.url)) |
| 18 | + |
| 19 | +export default defineConfig({ |
| 20 | + markdown: { |
| 21 | + shikiConfig: { |
| 22 | + transformers: [ |
| 23 | + { |
| 24 | + pre: node => { |
| 25 | + delete node.properties.tabindex |
| 26 | + delete node.properties.style |
| 27 | + }, |
| 28 | + }, |
| 29 | + ], |
| 30 | + theme: colorTheme, |
| 31 | + }, |
| 32 | + rehypePlugins: [ |
| 33 | + [ |
| 34 | + rehypeExternalLinks, |
| 35 | + { |
| 36 | + rel: ['noopener', 'noreferrer'], |
| 37 | + target: '_blank', |
| 38 | + }, |
| 39 | + ], |
| 40 | + ], |
| 41 | + remarkPlugins: [remarkSectionize, remarkHeadings], |
| 42 | + }, |
| 43 | + vite: { |
| 44 | + css: { |
| 45 | + lightningcss: { |
| 46 | + targets: browserslistToTargets( |
| 47 | + browserslist(null, { |
| 48 | + config: path.join(dirname, './.browserslistrc'), |
| 49 | + }), |
| 50 | + ), |
| 51 | + }, |
| 52 | + transformer: 'lightningcss', |
| 53 | + }, |
| 54 | + plugins: [ |
| 55 | + // @ts-ignore |
| 56 | + svelteSvg(), |
| 57 | + ], |
| 58 | + }, |
| 59 | + integrations: [ |
| 60 | + compress({ |
| 61 | + JavaScript: true, |
| 62 | + Image: true, |
| 63 | + CSS: false, |
| 64 | + HTML: true, |
| 65 | + SVG: true, |
| 66 | + }), |
| 67 | + svelte({ |
| 68 | + compilerOptions: { |
| 69 | + cssHash: ({ hash, css }) => `s-${hash(css)}`, |
| 70 | + discloseVersion: false, |
| 71 | + }, |
| 72 | + }), |
| 73 | + sitemap(), |
| 74 | + mdx(), |
| 75 | + ], |
| 76 | + prefetch: { |
| 77 | + defaultStrategy: 'viewport', |
| 78 | + prefetchAll: true, |
| 79 | + }, |
| 80 | + build: { |
| 81 | + inlineStylesheets: 'always', |
| 82 | + format: 'file', |
| 83 | + }, |
| 84 | + experimental: { |
| 85 | + clientPrerender: true, |
| 86 | + }, |
| 87 | + publicDir: path.join(dirname, './docs/public'), |
| 88 | + server: { |
| 89 | + port: 3000, |
| 90 | + host: true, |
| 91 | + }, |
| 92 | + srcDir: path.join(dirname, './docs'), |
| 93 | + root: path.join(dirname, './docs'), |
| 94 | + site: 'https://perfectionist.dev', |
| 95 | + compressHTML: true, |
| 96 | +}) |
0 commit comments