@@ -2,15 +2,19 @@ require('./check-versions')();
2
2
3
3
process . env . NODE_ENV = 'production' ;
4
4
5
- const fs = require ( 'fs' ) ;
6
- const path = require ( 'path' ) ;
7
5
const chalk = require ( 'chalk' ) ;
8
6
const webpack = require ( 'webpack' ) ;
9
- const { spawn } = require ( 'child_process' ) ;
10
7
const webpackConfig = require ( './webpack.prod.conf' ) ;
11
8
9
+ const isEsm = process . env . ESM ;
12
10
const isExampleEnv = process . env . EXAMPLE_ENV ;
13
11
12
+ const successText = {
13
+ main : 'Build main sources complete.' ,
14
+ esm : 'Build esm sources complete.' ,
15
+ example : 'Build example page complete.' ,
16
+ } ;
17
+
14
18
webpack ( webpackConfig , ( err , stats ) => {
15
19
if ( err ) throw err ;
16
20
@@ -29,7 +33,8 @@ webpack(webpackConfig, (err, stats) => {
29
33
process . exit ( 1 ) ;
30
34
}
31
35
32
- console . log ( chalk . cyan ( 'Build sources complete.\n' ) ) ;
36
+ const text = isExampleEnv ? successText . example : isEsm ? successText . esm : successText . main ;
37
+ console . log ( chalk . cyan ( `${ text } \n` ) ) ;
33
38
34
39
if ( isExampleEnv ) {
35
40
console . log (
@@ -38,21 +43,5 @@ webpack(webpackConfig, (err, stats) => {
38
43
"Opening index.html over file:// won't work.\n" ,
39
44
) ,
40
45
) ;
41
- } else {
42
- const buildEsmProcess = spawn ( 'npm' , [ 'run' , 'build:esm' ] , {
43
- stdio : 'inherit' ,
44
- } ) ;
45
-
46
- buildEsmProcess . on ( 'close' , ( ) => {
47
- console . log ( chalk . cyan ( 'Build esm complete.\n' ) ) ;
48
- } ) ;
49
-
50
- const buildTypesProcess = spawn ( 'npm' , [ 'run' , 'build:dts' ] , {
51
- stdio : 'inherit' ,
52
- } ) ;
53
-
54
- buildTypesProcess . on ( 'close' , ( ) => {
55
- console . log ( chalk . cyan ( 'Build types(.d.ts) complete.\n' ) ) ;
56
- } ) ;
57
46
}
58
47
} ) ;
0 commit comments