pikaos-site/astro.config.mjs
2023-01-10 17:16:37 +00:00

74 lines
1.5 KiB
JavaScript

import path from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import sitemap from '@astrojs/sitemap';
import image from '@astrojs/image';
import mdx from '@astrojs/mdx';
import partytown from '@astrojs/partytown';
import compress from 'astro-compress';
import { remarkReadingTime } from './src/utils/frontmatter.mjs';
import { SITE } from './src/config.mjs';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const whenExternalScripts = (items = []) =>
SITE.googleAnalyticsId ? (Array.isArray(items) ? items.map((item) => item()) : [items()]) : [];
export default defineConfig({
site: SITE.origin,
base: SITE.basePathname,
trailingSlash: SITE.trailingSlash ? 'always' : 'never',
output: 'static',
integrations: [
tailwind({
config: {
applyBaseStyles: false,
},
}),
sitemap(),
image({
serviceEntryPoint: '@astrojs/image/sharp',
}),
mdx(),
...whenExternalScripts(() =>
partytown({
config: { forward: ['dataLayer.push'] },
})
),
compress({
css: true,
html: true,
img: true,
js: true,
svg: true,
logger: 1,
}),
],
markdown: {
remarkPlugins: [remarkReadingTime],
extendDefaultPlugins: true,
},
vite: {
resolve: {
alias: {
'~': path.resolve(__dirname, './src'),
},
},
},
experimental: {
contentCollections: true,
},
});