File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "type" : " module" ,
55 "scripts" : {
66 "build" : " rs build" ,
7- "dev" : " rs dev --open " ,
7+ "dev" : " rs dev" ,
88 "preview" : " rs preview"
99 },
1010 "dependencies" : {
Original file line number Diff line number Diff line change 11import cac from 'cac' ;
22import { logger } from '@rsbuild/core' ;
33import { initRsbuild } from './rsbuild.js' ;
4- import type { BuildOptions } from './types.js' ;
4+ import type { BuildOptions , DevOptions } from './types.js' ;
55
66declare global {
77 const RSTACK_VERSION : string ;
@@ -12,6 +12,22 @@ export function setupCommands(): void {
1212
1313 cli . version ( RSTACK_VERSION ) ;
1414
15+ cli . command ( 'dev' , 'Start the Rsbuild dev server' ) . action ( async ( options : DevOptions ) => {
16+ try {
17+ const rsbuild = await initRsbuild ( {
18+ options,
19+ } ) ;
20+ if ( ! rsbuild ) {
21+ return ;
22+ }
23+ await rsbuild . startDevServer ( ) ;
24+ } catch ( err ) {
25+ logger . error ( 'Failed to start dev server.' ) ;
26+ logger . error ( err ) ;
27+ process . exit ( 1 ) ;
28+ }
29+ } ) ;
30+
1531 cli
1632 . command ( 'build' , 'Run Rsbuild to build the app for production' )
1733 . option ( '-w, --watch' , 'Enable watch mode to automatically rebuild on file changes' )
Original file line number Diff line number Diff line change @@ -6,3 +6,5 @@ export type BuildOptions = {
66 root ?: string ;
77 watch ?: boolean ;
88} ;
9+
10+ export type DevOptions = RsbuildCommonOptions ;
You can’t perform that action at this time.
0 commit comments