File tree 2 files changed +33
-4
lines changed
packages/@vue/cli-service
2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ test('api: configureWebpack', () => {
253
253
} ] )
254
254
255
255
const config = service . resolveWebpackConfig ( )
256
+ console . log ( process . env . VUE_CLI_ENTRY_FILES )
256
257
expect ( config . output . path ) . toBe ( 'test-dist-2' )
257
258
} )
258
259
@@ -296,6 +297,23 @@ test('api: configureWebpack preserve ruleNames', () => {
296
297
expect ( config . module . rules [ 0 ] . __ruleNames ) . toEqual ( [ 'js' ] )
297
298
} )
298
299
300
+ test . only ( 'internal: should correctly set VUE_CLI_ENTRY_FILES' , ( ) => {
Has comments. Original line has comments.
301
+ const service = createMockService ( [ {
302
+ id : 'test' ,
303
+ apply : api => {
304
+ api . configureWebpack ( config => {
305
+ config . entry = {
306
+ page1 : './src/page1.js' ,
307
+ page2 : './src/page2.js'
308
+ }
309
+ } )
310
+ }
311
+ } ] )
312
+
313
+ service . resolveWebpackConfig ( )
314
+ expect ( process . env . VUE_CLI_ENTRY_FILES ) . toEqual ( '["/src/page1.js","/src/page2.js"]' )
315
+ } )
316
+
299
317
test ( 'api: configureDevServer' , ( ) => {
300
318
const cb = ( ) => { }
301
319
const service = createMockService ( [ {
Original file line number Diff line number Diff line change @@ -270,10 +270,21 @@ module.exports = class Service {
270
270
)
271
271
}
272
272
273
- const entryFiles = Object . values ( config . entry || [ ] ) . reduce ( ( allEntries , curr ) => {
274
- return allEntries . concat ( curr )
275
- } , [ ] )
276
- process . env . VUE_CLI_ENTRY_FILES = JSON . stringify ( entryFiles )
273
+ if ( typeof config . entry !== 'function' ) {
274
+ let entryFiles
275
+ if ( typeof config . entry === 'string' ) {
276
+ entryFiles = [ config . entry ]
277
+ } else if ( Array . isArray ( config . entry ) ) {
278
+ entryFiles = config . entry
279
+ } else {
280
+ entryFiles = Object . values ( config . entry || [ ] ) . reduce ( ( allEntries , curr ) => {
281
+ return allEntries . concat ( curr )
282
+ } , [ ] )
283
+ }
284
+
285
+ entryFiles = entryFiles . map ( file => path . resolve ( this . context , file ) )
286
+ process . env . VUE_CLI_ENTRY_FILES = JSON . stringify ( entryFiles )
287
+ }
277
288
278
289
return config
279
290
}
You can’t perform that action at this time.