@@ -36,7 +36,7 @@ module.exports = (api, options) => {
36
36
'--report-json' : 'generate report.json to help analyze bundle content' ,
37
37
'--watch' : `watch for changes`
38
38
}
39
- } , async ( args ) => {
39
+ } , async ( args , rawArgs ) => {
40
40
for ( const key in defaults ) {
41
41
if ( args [ key ] == null ) {
42
42
args [ key ] = defaults [ key ]
@@ -50,20 +50,29 @@ module.exports = (api, options) => {
50
50
process . env . VUE_CLI_BUILD_TARGET = args . target
51
51
if ( args . modern && args . target === 'app' ) {
52
52
process . env . VUE_CLI_MODERN_MODE = true
53
- delete process . env . VUE_CLI_MODERN_BUILD
54
- await build ( Object . assign ( { } , args , {
55
- modernBuild : false ,
56
- keepAlive : true
57
- } ) , api , options )
58
-
59
- process . env . VUE_CLI_MODERN_BUILD = true
60
- await build ( Object . assign ( { } , args , {
61
- modernBuild : true ,
62
- clean : false
63
- } ) , api , options )
64
-
53
+ if ( ! process . env . VUE_CLI_MODERN_BUILD ) {
54
+ // main-process for legacy build
55
+ await build ( Object . assign ( { } , args , {
56
+ modernBuild : false ,
57
+ keepAlive : true
58
+ } ) , api , options )
59
+ // spawn sub-process of self for modern build
60
+ const { execa } = require ( '@vue/cli-shared-utils' )
61
+ const cliBin = api . resolve ( 'node_modules/.bin/vue-cli-service' )
62
+ await execa ( cliBin , [ 'build' , ...rawArgs ] , {
63
+ stdio : 'inherit' ,
64
+ env : {
65
+ VUE_CLI_MODERN_BUILD : true
66
+ }
67
+ } )
68
+ } else {
69
+ // sub-process for modern build
70
+ await build ( Object . assign ( { } , args , {
71
+ modernBuild : true ,
72
+ clean : false
73
+ } ) , api , options )
74
+ }
65
75
delete process . env . VUE_CLI_MODERN_MODE
66
- delete process . env . VUE_CLI_MODERN_BUILD
67
76
} else {
68
77
if ( args . modern ) {
69
78
const { warn } = require ( '@vue/cli-shared-utils' )
0 commit comments