File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
packages/@vue/cli-service Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ test('api: configureWebpack', () => {
253253 } ] )
254254
255255 const config = service . resolveWebpackConfig ( )
256+ console . log ( process . env . VUE_CLI_ENTRY_FILES )
256257 expect ( config . output . path ) . toBe ( 'test-dist-2' )
257258} )
258259
@@ -296,6 +297,23 @@ test('api: configureWebpack preserve ruleNames', () => {
296297 expect ( config . module . rules [ 0 ] . __ruleNames ) . toEqual ( [ 'js' ] )
297298} )
298299
300+ test . only ( 'internal: should correctly set VUE_CLI_ENTRY_FILES' , ( ) => {
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+
299317test ( 'api: configureDevServer' , ( ) => {
300318 const cb = ( ) => { }
301319 const service = createMockService ( [ {
Original file line number Diff line number Diff line change @@ -270,10 +270,21 @@ module.exports = class Service {
270270 )
271271 }
272272
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+ }
277288
278289 return config
279290 }
You can’t perform that action at this time.
0 commit comments