import { defineConfig, Plugin } from 'vite'; import react from '@vitejs/plugin-react'; import { VitePWA } from 'vite-plugin-pwa'; import mdx from '@mdx-js/rollup'; import remarkFrontmatter from 'remark-frontmatter'; import remarkMdxFrontmatter from 'remark-mdx-frontmatter'; // Plugin to make CSS non-blocking and remove unnecessary preloads function asyncCssPlugin(): Plugin { return { name: 'async-css', enforce: 'post', transformIndexHtml(html) { // Convert blocking CSS to async loading html = html.replace( //g, ` ` ); // Remove modulepreload for non-critical chunks (animations, icons loaded later) html = html.replace(/\n?/g, ''); html = html.replace(/\n?/g, ''); // Add high priority preload for entry script const mainScriptMatch = html.match(/