132 lines
3.2 KiB
JavaScript
132 lines
3.2 KiB
JavaScript
import { defineConfig } from 'astro/config'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { imagetools } from "imagetools"
|
|
import react from "@astrojs/react"
|
|
import mdx from "@astrojs/mdx";
|
|
import { defineConfig } from 'astro/config';
|
|
import compress from 'vite-plugin-compression';
|
|
import sitemap from "@astrojs/sitemap";
|
|
import toc from '@jsdevtools/rehype-toc'
|
|
|
|
import { rehypeAccessibleEmojis } from 'rehype-accessible-emojis';
|
|
import getReadingTime from 'reading-time';
|
|
import { toString } from 'mdast-util-to-string';
|
|
|
|
export function remarkReadingTime() {
|
|
return function (tree, { data }) {
|
|
const textOnPage = toString(tree);
|
|
const readingTime = getReadingTime(textOnPage);
|
|
// readingTime.text will give us minutes read as a friendly string,
|
|
// i.e. "3 min read"
|
|
data.astro.frontmatter.minutesRead = readingTime.text;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @link : https://github.com/rehypejs/rehype/blob/main/doc/plugins.md
|
|
*/
|
|
|
|
export default defineConfig({
|
|
site: 'https://polymech.io',
|
|
devToolbar: {
|
|
enabled: false,
|
|
},
|
|
i18n: {
|
|
locales: ["es", "en", "de", "fr", "it", "ar", "ja", "zh", "nl", "it", "pt"],
|
|
defaultLocale: "en",
|
|
},
|
|
vite: {
|
|
resolve: {
|
|
alias: {
|
|
'@components': '/src/components',
|
|
'@layouts': '/src/layouts',
|
|
'img': '',
|
|
}
|
|
},
|
|
plugins: [
|
|
tailwindcss({
|
|
config: './tailwind.config.cjs',
|
|
jit: true
|
|
}),
|
|
compress({
|
|
algorithm: 'gzip', // You can also use 'brotliCompress' for Brotli
|
|
threshold: 1024, // Compress files larger than 1KB
|
|
deleteOriginFile: false, // Keep original files (optional)
|
|
}),
|
|
{
|
|
name: 'auto-import-img',
|
|
transform(code, id) {
|
|
if (id.endsWith('.astro') || id.endsWith('.mdx')) {
|
|
return `import { Img } from 'imagetools/components';\n` + code;
|
|
}
|
|
},
|
|
},
|
|
],
|
|
build: {
|
|
target: 'esnext',
|
|
assetsDir: './assets',
|
|
modulePreload: { polyfill: false },
|
|
commonjsOptions: { esmExternals: true },
|
|
assetsInlineLimit: 1024,
|
|
sourcemap: false,
|
|
},
|
|
ssr: {
|
|
external: ['cacache', 'glob', 'xlsx', 'sharp', '@polymech/kbot-d']
|
|
}
|
|
},
|
|
markdown: {
|
|
drafts: true,
|
|
shikiConfig: {
|
|
theme: "github-light-default"
|
|
}
|
|
},
|
|
shikiConfig: {
|
|
wrap: true,
|
|
skipInline: false,
|
|
drafts: true
|
|
},
|
|
integrations: [
|
|
//starlight(),
|
|
sitemap({
|
|
|
|
}),
|
|
mdx({
|
|
rehypePlugins: [
|
|
rehypeAccessibleEmojis,
|
|
remarkReadingTime,
|
|
toc,
|
|
() => {
|
|
// All remark and rehype plugins return a separate function
|
|
return function (tree, file) {
|
|
file.data.astro.frontmatter.customProperty = 'Generated property';
|
|
}
|
|
}
|
|
],
|
|
}),
|
|
//AstroPWA({}),
|
|
react(),
|
|
imagetools,
|
|
/*
|
|
webmanifest({
|
|
name: 'PolyMech',
|
|
icon: 'public/logos/transparent.svg',
|
|
short_name: 'App',
|
|
description: 'Here she comes again :)',
|
|
start_url: '/',
|
|
theme_color: '#3367D6',
|
|
background_color: '#3367D6',
|
|
display: 'standalone',
|
|
})
|
|
*/
|
|
]
|
|
});
|
|
/*
|
|
experimental: {
|
|
responsiveImages: true,
|
|
contentIntellisense: true,
|
|
session: {
|
|
// Required: the name of the unstorage driver
|
|
driver: "fs",
|
|
},
|
|
},
|
|
*/ |