Skip to content

Commit

Permalink
fix: lazy load @vue/server-render for production build
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 26, 2020
1 parent 255a2c4 commit 382e1b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/node/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/node/build/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 382e1b6

Please sign in to comment.