@@ -37,6 +37,11 @@ module.exports = (api, options) => {
37
37
? true
38
38
: pluginOptions . bundleMainProcess
39
39
40
+ const removeArg = ( arg , count , rawArgs ) => {
41
+ const index = rawArgs . indexOf ( arg )
42
+ if ( index !== - 1 ) rawArgs . splice ( index , count )
43
+ }
44
+
40
45
// Apply custom webpack config
41
46
api . chainWebpack ( async config => {
42
47
chainWebpack ( api , pluginOptions , config )
@@ -62,15 +67,11 @@ module.exports = (api, options) => {
62
67
const configureBuildCommand = require ( 'electron-builder/out/builder' )
63
68
. configureBuildCommand
64
69
// Prevent custom args from interfering with electron-builder
65
- const removeArg = ( arg , count ) => {
66
- const index = rawArgs . indexOf ( arg )
67
- if ( index !== - 1 ) rawArgs . splice ( index , count )
68
- }
69
- removeArg ( '--mode' , 2 )
70
- removeArg ( '--dest' , 2 )
71
- removeArg ( '--legacy' , 1 )
72
- removeArg ( '--dashboard' , 1 )
73
- removeArg ( '--skipBundle' , 1 )
70
+ removeArg ( '--mode' , 2 , rawArgs )
71
+ removeArg ( '--dest' , 2 , rawArgs )
72
+ removeArg ( '--legacy' , 1 , rawArgs )
73
+ removeArg ( '--dashboard' , 1 , rawArgs )
74
+ removeArg ( '--skipBundle' , 1 , rawArgs )
74
75
// Parse the raw arguments using electron-builder yargs config
75
76
const builderArgs = yargs
76
77
. command ( [ 'build' , '*' ] , 'Build' , configureBuildCommand )
@@ -200,7 +201,7 @@ module.exports = (api, options) => {
200
201
usage : 'vue-cli-service serve:electron' ,
201
202
details : `See https://nklayman.github.io/vue-cli-plugin-electron-builder/ for more details about this plugin.`
202
203
} ,
203
- async args => {
204
+ async ( args , rawArgs ) => {
204
205
// Use custom config for webpack
205
206
process . env . IS_ELECTRON = true
206
207
const execa = require ( 'execa' )
@@ -210,6 +211,11 @@ module.exports = (api, options) => {
210
211
]
211
212
const mainProcessArgs = pluginOptions . mainProcessArgs || [ ]
212
213
214
+ // Don't pass command args to electron
215
+ removeArg ( '--dashboard' , 1 , rawArgs )
216
+ removeArg ( '--debug' , 1 , rawArgs )
217
+ removeArg ( '--headless' , 1 , rawArgs )
218
+
213
219
// Run the serve command
214
220
const server = await api . service . run ( 'serve' , {
215
221
_ : [ ] ,
@@ -358,6 +364,8 @@ module.exports = (api, options) => {
358
364
info (
359
365
'Launching Electron with arguments: "' +
360
366
mainProcessArgs . join ( ' ' ) +
367
+ ' ' +
368
+ rawArgs . join ( ' ' ) +
361
369
'" ...'
362
370
)
363
371
} else {
@@ -378,7 +386,9 @@ module.exports = (api, options) => {
378
386
// Have it load the main process file built with webpack
379
387
outputDir ,
380
388
// Append other arguments specified in plugin options
381
- ...mainProcessArgs
389
+ ...mainProcessArgs ,
390
+ // Append args passed to command
391
+ ...rawArgs
382
392
] ,
383
393
{
384
394
cwd : api . resolve ( '.' ) ,
0 commit comments