@@ -10,8 +10,8 @@ function run(cmd, args) {
10
10
11
11
async function main ( ) {
12
12
const reactConsumers = [
13
- { dir : 'combination-of-4' , port : 3001 } ,
14
- { dir : 'combination-of-5' , port : 3002 } ,
13
+ { dir : 'combination-of-4' , port : 3001 , serve : true } ,
14
+ { dir : 'combination-of-5' , port : 3002 , serve : true } ,
15
15
{ dir : 'css-and-styled-component' , port : 3003 } ,
16
16
{ dir : 'css-module-and-jss' , port : 3004 } ,
17
17
{ dir : 'less-and-scss' , port : 3005 } ,
@@ -22,19 +22,31 @@ async function main() {
22
22
const exposes = [ 4000 , 4001 , 4002 , 4003 , 4004 , 4005 , 4006 , 4007 ] ;
23
23
24
24
const nextConsumers = [
25
- { dir : 'combination-of-4' , port : 8081 } ,
26
- { dir : 'jss-and-tailwind-global' , port : 8082 } ,
27
25
{ dir : 'jss-css-and-tailwind-module' , port : 8083 } ,
26
+ { dir : 'jss-and-tailwind-global' , port : 8082 } ,
28
27
{ dir : 'less-and-styled-component' , port : 8084 } ,
28
+ { dir : 'combination-of-4' , port : 8081 } ,
29
29
] ;
30
30
31
31
const procs = [ ] ;
32
32
33
- console . log ( '[federated-css] starting consumers-react (sequential dev servers)...' ) ;
34
- for ( const { dir, port } of reactConsumers ) {
33
+ console . log ( '[federated-css] starting consumers-react (sequential servers)...' ) ;
34
+ for ( const { dir, port, serve } of reactConsumers ) {
35
35
const cwd = path . join ( 'consumers-react' , dir ) ;
36
- const p = run ( 'pnpm' , [ '-C' , cwd , 'run' , 'start' ] ) ;
37
- procs . push ( p ) ;
36
+
37
+ if ( serve ) {
38
+ console . log ( `[federated-css] building consumers-react ${ dir } for static serve...` ) ;
39
+ await new Promise ( ( res , rej ) => {
40
+ const buildProc = run ( 'pnpm' , [ '-C' , cwd , 'run' , 'build' ] ) ;
41
+ buildProc . on ( 'exit' , code => ( code === 0 ? res ( ) : rej ( new Error ( `build ${ dir } failed` ) ) ) ) ;
42
+ } ) ;
43
+ const serveProc = run ( 'pnpm' , [ '-C' , cwd , 'run' , 'serve' ] ) ;
44
+ procs . push ( serveProc ) ;
45
+ } else {
46
+ const devProc = run ( 'pnpm' , [ '-C' , cwd , 'run' , 'start' ] ) ;
47
+ procs . push ( devProc ) ;
48
+ }
49
+
38
50
await waitOn ( { resources : [ `http://localhost:${ port } ` ] , timeout : 480000 , validateStatus : s => s >= 200 && s < 500 } ) ;
39
51
console . log ( `[federated-css] consumers-react ${ dir } up at ${ port } ` ) ;
40
52
}
0 commit comments