11import type { CreateVueAppFunction } from '@vuepress/client'
22import type { App , Bundler } from '@vuepress/core'
3- import { chalk , fs , importFile , ora , withSpinner } from '@vuepress/utils'
3+ import { chalk , debug , fs , importFile , withSpinner } from '@vuepress/utils'
44import type { OutputAsset , OutputChunk , RollupOutput } from 'rollup'
55import { build as viteBuild } from 'vite'
66import { resolveViteConfig } from '../resolveViteConfig.js'
77import type { ViteBundlerOptions } from '../types.js'
88import { renderPage } from './renderPage.js'
99
10+ const log = debug ( 'vuepress:bundler-vite/build' )
11+
1012export const build = async (
1113 options : ViteBundlerOptions ,
1214 app : App
@@ -15,6 +17,7 @@ export const build = async (
1517 await app . pluginApi . hooks . extendsBundlerOptions . process ( options , app )
1618
1719 // vite compile
20+ log ( 'compiling start' )
1821 let clientOutput ! : RollupOutput
1922 let serverOutput ! : RollupOutput
2023 await withSpinner ( 'Compiling with vite' ) ( async ( ) => {
@@ -37,9 +40,10 @@ export const build = async (
3740 viteBuild ( serverConfig ) as Promise < RollupOutput > ,
3841 ] )
3942 } )
43+ log ( 'compiling finish' )
4044
4145 // render pages
42- await withSpinner ( ' Rendering pages' ) ( async ( ) => {
46+ await withSpinner ( ` Rendering ${ app . pages . length } pages` ) ( async ( spinner ) => {
4347 // load ssr template file
4448 const ssrTemplate = (
4549 await fs . readFile ( app . options . templateBuild )
@@ -66,9 +70,10 @@ export const build = async (
6670 } > ( serverEntryPath )
6771
6872 // pre-render pages to html files
69- const spinner = ora ( )
7073 for ( const page of app . pages ) {
71- spinner . start ( `Rendering pages ${ chalk . magenta ( page . path ) } ` )
74+ if ( spinner ) {
75+ spinner . text = `Rendering pages ${ chalk . magenta ( page . path ) } `
76+ }
7277 await renderPage ( {
7378 app,
7479 page,
@@ -79,7 +84,6 @@ export const build = async (
7984 outputCssAsset : clientCssAsset ,
8085 } )
8186 }
82- spinner . stop ( )
8387 } )
8488
8589 // keep the server bundle files in debug mode
0 commit comments