@@ -66,6 +66,7 @@ var options = merge({
66
66
host : 'localhost'
67
67
} , localConfig , {
68
68
entry : args [ 0 ] ,
69
+ config : program . config ,
69
70
port : program . port ,
70
71
host : program . host ,
71
72
open : program . open ,
@@ -81,7 +82,7 @@ var options = merge({
81
82
} )
82
83
83
84
function help ( ) {
84
- if ( ! options . run && ! options . entry ) {
85
+ if ( ! options . config && ! options . entry ) {
85
86
return program . help ( )
86
87
}
87
88
}
@@ -218,6 +219,10 @@ if (options.mount === undefined && !options.lib && /\.vue$/.test(options.entry))
218
219
if ( options . mount ) {
219
220
webpackConfig . entry . client . push ( ownDir ( 'lib/default-entry.es6' ) )
220
221
webpackConfig . resolve . alias [ 'your-tasteful-component' ] = cwd ( options . entry )
222
+ } else if ( Array . isArray ( options . entry ) ) {
223
+ webpackConfig . entry . client = options . client
224
+ } else if ( typeof options . entry === 'object' ) {
225
+ webpackConfig . entry = options . entry
221
226
} else {
222
227
webpackConfig . entry . client . push ( options . entry )
223
228
}
@@ -232,12 +237,16 @@ if (options.lib) {
232
237
webpackConfig . output . libraryTarget = 'umd'
233
238
} else {
234
239
// only output index.html in non-lib mode
235
- webpackConfig . plugins . unshift (
236
- new HtmlWebpackPlugin ( Object . assign ( {
237
- title : 'Vue App' ,
238
- template : ownDir ( 'lib/template.html' )
239
- } , options . html ) )
240
- )
240
+ var html = Array . isArray ( options . html ) ? options . html : [ options . html || { } ]
241
+
242
+ html . forEach ( item => {
243
+ webpackConfig . plugins . unshift (
244
+ new HtmlWebpackPlugin ( Object . assign ( {
245
+ title : 'Vue App' ,
246
+ template : ownDir ( 'lib/template.html' )
247
+ } , item ) )
248
+ )
249
+ } )
241
250
}
242
251
243
252
// installed by `yarn global add`
@@ -282,10 +291,6 @@ if (production) {
282
291
} ) )
283
292
}
284
293
} else {
285
- if ( ! options . watch ) {
286
- webpackConfig . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) )
287
- webpackConfig . entry . client . unshift ( require . resolve ( 'webpack-hot-middleware/client' ) + `?reload=true&path=http://${ options . host } :${ options . port } /__webpack_hmr` )
288
- }
289
294
webpackConfig . devtool = 'eval-source-map'
290
295
webpackConfig . plugins . push (
291
296
new FriendlyErrorsPlugin ( ) ,
@@ -316,8 +321,21 @@ if (!options.disableWebpackConfig) {
316
321
}
317
322
}
318
323
319
- // only check entry when there's no custom `run` process
320
- if ( ! options . run && ! fs . existsSync ( options . entry ) ) {
324
+ if ( ! options . watch && ! options . production ) {
325
+ webpackConfig . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) )
326
+ var hmrEntries = options . hmrEntries || [ 'client' ]
327
+ var hmrClient = require . resolve ( 'webpack-hot-middleware/client' ) + `?reload=true&path=http://${ options . host } :${ options . port } /__webpack_hmr`
328
+ hmrEntries . forEach ( name => {
329
+ if ( Array . isArray ( webpackConfig . entry [ name ] ) ) {
330
+ webpackConfig . entry [ name ] . unshift ( hmrClient )
331
+ } else {
332
+ webpackConfig . entry [ name ] = [ hmrClient , webpackConfig . entry [ name ] ]
333
+ }
334
+ } )
335
+ }
336
+
337
+ // only check entry when there's no custom config
338
+ if ( ! options . config && ! fs . existsSync ( options . entry ) ) {
321
339
logger . fatal ( `${ chalk . yellow ( options . entry ) } does not exist, did you forget to create one?` )
322
340
}
323
341
0 commit comments