Closed ben-lau closed 2 months ago
What's prerender plugin? Do you mean Pre-rendering? Can you share your vite's conf?
yep, the prerender plugin use puppeteer to render html.
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import compression from 'vite-plugin-compression2';
import prerender from '@prerenderer/rollup-plugin';
import basicSsl from '@vitejs/plugin-basic-ssl';
import { analyzer } from 'vite-bundle-analyzer';
export default defineConfig({
esbuild: { drop: ['console'] },
plugins: [
vue(),
vueJsx(),
prerender({
routes: ['/'],
renderer: '@prerenderer/renderer-puppeteer',
rendererOptions: {
renderAfterDocumentEvent: 'custom-render-trigger',
headless: false,
injectProperty: '__IS_PRERENDERING__',
inject: '__IS_PRERENDERING__',
},
}),
basicSsl(),
compression(),
// analyzer(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
});
@ben-lau v1.2.0 released. Try it.
Perfect , it's working great!
I use prerender plugin in my project, it will launch a browser with my compile product at the stage
generateBundle
, but this plugin completes the compression before that. Cause my html inside gz is the origin template, not the prerendered one, but outside the gz file, there is the prerendered html file. Can it be solved? Thank you.