提交 e202b17a 编写于 作者: dsyuan001's avatar dsyuan001

public html

上级 c0553154
......@@ -70,9 +70,9 @@ html页时,可实现热更新。
| removeStyle | boolean | 移除预览服务生成多余样式,默认true。如样式丢失,可设置为false |
| callback | funtion(html,route) | 预渲染和处理public下.html文件处理回调事件,可对需处理的页面进行修改,html为将要生成的文件内容,route当前处理的页面path |
| publicHtml | boolean/string[] | 需要处理的纯静态文件。true代表public整个目录下的html文件,数组时可指定文件,如['/contact/index.html'] |
| scss | [{entry,outDir}] | 需要编辑的单独scss文件。专为单独纯html定制,可将独立(即没有项目里引入)的scss转换为css |
| scss | [{entry,outDir}] | 需要编辑的单独scss文件。专为单独纯html定制,可将独立(即没有在项目里引入)的scss转换为css |
## 附:seo关键词优化设置
## 附:seo关键词优化路由设置
```ts
// router.ts
......
......@@ -10,6 +10,7 @@
"publish": "pnpm --filter ./packages tsup"
},
"dependencies": {
"vite-plugin-seo-prerender": "^0.1.0",
"vue": "^3.3.4",
"vue-router": "^4.2.2"
},
......
......@@ -70,9 +70,9 @@ html页时,可实现热更新。
| removeStyle | boolean | 移除预览服务生成多余样式,默认true。如样式丢失,可设置为false |
| callback | funtion(html,route) | 预渲染和处理public下.html文件处理回调事件,可对需处理的页面进行修改,html为将要生成的文件内容,route当前处理的页面path |
| publicHtml | boolean/string[] | 需要处理的纯静态文件。true代表public整个目录下的html文件,数组时可指定文件,如['/contact/index.html'] |
| scss | [{entry,outDir}] | 需要编辑的单独scss文件。专为单独纯html定制,可将独立(即没有项目里引入)的scss转换为css |
| scss | [{entry,outDir}] | 需要编辑的单独scss文件。专为单独纯html定制,可将独立(即没有在项目里引入)的scss转换为css |
## 附:seo关键词优化设置
## 附:seo关键词优化路由设置
```ts
// router.ts
......
{
"name": "vite-plugin-seo-prerender",
"version": "0.1.0-beta.1",
"version": "0.1.0",
"description": "`vite-plugin-seo-prerender` 插件是一个用于 `Vite` 构建工具的预渲染插件,它可以将你的单页面应用 (SPA) 在构建时静态预渲染为 HTML 文件,以提高首次加载速度和SEO友好性。适用于对站点少量页面生成静态HTML。支持 `Vue、React`等所有框架",
"license": "MIT",
"author": "337547038",
......
......@@ -11,7 +11,7 @@ const seoPrerender = async (config) => {
for (const item of config.routes) {
await page.goto(path.join(config.local, item))
await page.setViewport({width: 1024, height: 768})
let content = await page.content()
let content: string = await page.content()
if (config.removeStyle !== false) {
// 若出现导常,可设置参数removeStyle:false
content = content.replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "");
......
此差异已折叠。
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
//import seoPrerender from 'vite-plugin-seo-prerender'
import seoPrerender from './packages/src'
import seoPrerender from 'vite-plugin-seo-prerender'
//import seoPrerender from './packages/src'
// https://vitejs.dev/config/
export default defineConfig({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册