File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -18,20 +18,36 @@ const PORT = 3000;
1818
1919export class App {
2020 constructor ( ) {
21- const compiler = webpack ( {
21+ this . compiler = webpack ( {
2222 mode : "development" ,
23- entry : path . join ( __dirname , "../index.js" )
23+ entry : path . join ( __dirname , "../index.js" ) ,
24+ output : {
25+ path : path . join ( __dirname , "../dist" ) ,
26+ filename : "index.js" ,
27+ }
2428 } ) ;
2529
2630 this . server = new DevServer ( {
2731 static : {
2832 directory : path . join ( __dirname , "../" ) ,
2933 } ,
3034 port : 3000 ,
31- } , compiler ) ;
35+ } , this . compiler ) ;
36+ }
37+
38+ async build ( ) {
39+ await new Promise ( ( resolve , reject ) => {
40+ this . compiler . run ( err => {
41+ if ( err ) reject ( err ) ;
42+ resolve ( ) ;
43+
44+ this . compiler . close ( closeErr => reject ( closeErr ) ) ;
45+ } ) ;
46+ } ) ;
3247 }
3348
3449 async start ( ) {
50+ await this . build ( ) ;
3551 console . log ( "Starting server..." ) ;
3652 await this . server . start ( ) ;
3753 }
You can’t perform that action at this time.
0 commit comments