vite-plugin-seo-prerender
Version:
`vite-plugin-seo-prerender` 插件是一个用于 `Vite` 构建工具的预渲染插件,它可以将你的单页面应用 (SPA) 在构建时静态预渲染为 HTML 文件,以提高首次加载速度和SEO友好性。适用于对站点少量页面生成静态HTML。支持 `Vue、React`等所有框架
31 lines (28 loc) • 1.45 kB
TypeScript
import { Plugin } from 'vite';
interface Config {
/** 生成预渲染的路由path */
routes: string[];
/** puppeteer一些配置 */
puppeteer?: any;
/** 构建时是否获取异步数据并注入到预渲染的 HTML 文件中,默认false 。开启后构建速度相对会慢些 */
network?: boolean;
/** 移除预览服务生成多余样式,默认true。如样式丢失,可设置为false */
removeStyle?: boolean;
/** 预渲染和处理public下.html文件处理回调事件,可对需处理的页面进行修改,html为将要生成的文件内容,route当前处理的页面path */
callback?: (html: string, route: string) => string;
/** 需要处理的其他纯静态文件。true代表public整个目录下的html文件,数组时可指定文件,如['/contact/index.html'] */
publicHtml?: boolean | string[];
/** 需要编译的单独scss文件。专为单独纯html页面量身定制,可将独立(即没有在项目里引入)的scss转换为css */
scss?: {
entry: string;
outDir: string;
}[];
/** 路由模式为hashHistory时需设置为true */
hashHistory?: boolean;
/** 延时等待时间,确保页面加载完成 */
delay?: number;
/** 并行处理数量。默认为 1,即不并行处理 */
concurrency?: number;
}
declare const seoPrerender: (config: Config) => Plugin;
export { type Config, seoPrerender as default };