fix: lazy load @vue/server-render for production build

pull/20/head
Evan You 5 years ago
parent 255a2c4853
commit 382e1b6514

@ -14,6 +14,7 @@ export type BuildOptions = Pick<
>
export async function build(buildOptions: BuildOptions = {}) {
process.env.NODE_ENV = 'production'
const siteConfig = await resolveConfig(buildOptions.root)
try {
const [clientResult, , pageToHashMap] = await bundle(

@ -3,7 +3,6 @@ import fs from 'fs-extra'
import { SiteConfig } from '../config'
import { HeadConfig } from '../../../types/shared'
import { BuildResult } from 'vite'
import { renderToString } from '@vue/server-renderer'
import { OutputChunk, OutputAsset } from 'rollup'
const escape = require('escape-html')
@ -21,7 +20,8 @@ export async function renderPage(
const { app, router } = createApp()
const routePath = `/${page.replace(/\.md$/, '')}`
router.go(routePath)
const content = await renderToString(app)
// lazy require server-renderer for production build
const content = await require('@vue/server-renderer').renderToString(app)
const pageName = page.replace(/\//g, '_')
// server build doesn't need hash

Loading…
Cancel
Save