feat: add --skipBuild flag to preview command (#44)
This commit is contained in:
parent
97a62b75f2
commit
caafa1355d
|
@ -92,12 +92,13 @@ cli.command('build [root]', 'build for production').action(async (root: string,
|
|||
// preview
|
||||
cli
|
||||
.command('preview [root]', 'start electron app to preview production build')
|
||||
.action(async (root: string, options: GlobalCLIOptions) => {
|
||||
.option('--skipBuild', `[boolean] skip build`)
|
||||
.action(async (root: string, options: { skipBuild?: boolean } & GlobalCLIOptions) => {
|
||||
const { preview } = await import('./preview')
|
||||
const inlineConfig = createInlineConfig(root, options)
|
||||
|
||||
try {
|
||||
await preview(inlineConfig)
|
||||
await preview(inlineConfig, { skipBuild: options.skipBuild })
|
||||
} catch (e) {
|
||||
const error = e as Error
|
||||
createLogger(options.logLevel).error(colors.red(`error during preview electron app:\n${error.stack}`), { error })
|
||||
|
|
|
@ -4,8 +4,10 @@ import type { InlineConfig } from './config'
|
|||
import { startElectron } from './electron'
|
||||
import { build } from './build'
|
||||
|
||||
export async function preview(inlineConfig: InlineConfig = {}): Promise<void> {
|
||||
await build(inlineConfig)
|
||||
export async function preview(inlineConfig: InlineConfig = {}, options: { skipBuild?: boolean }): Promise<void> {
|
||||
if (!options.skipBuild) {
|
||||
await build(inlineConfig)
|
||||
}
|
||||
|
||||
const logger = createLogger(inlineConfig.logLevel)
|
||||
|
||||
|
|
Loading…
Reference in a new issue