File tree Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,35 @@ describe('electron:build', () => {
317
317
expect ( options . baseUrl ) . toBe ( 'expected' )
318
318
expect ( options . publicPath ) . toBe ( 'expected' )
319
319
} )
320
+
321
+ test ( 'Adds mock legacy assets file for index' , async ( ) => {
322
+ await runCommand ( 'electron:build' )
323
+ expect ( fs . writeFileSync ) . toBeCalledWith (
324
+ 'dist_electron/bundled/legacy-assets-index.html.json' ,
325
+ '[]'
326
+ )
327
+ } )
328
+
329
+ test . each ( [ 'string config' , 'object config' ] ) (
330
+ 'Adds mock legacy assets file for each page (%s)' ,
331
+ async configType => {
332
+ const stringConfig = configType === 'string config'
333
+ await runCommand ( 'electron:build' , {
334
+ pages : {
335
+ index : stringConfig ? '' : { fileName : 'index.html' } ,
336
+ subpage : stringConfig ? '' : { fileName : 'subpage.html' }
337
+ }
338
+ } )
339
+ expect ( fs . writeFileSync ) . toBeCalledWith (
340
+ 'dist_electron/bundled/legacy-assets-index.html.json' ,
341
+ '[]'
342
+ )
343
+ expect ( fs . writeFileSync ) . toBeCalledWith (
344
+ 'dist_electron/bundled/legacy-assets-subpage.html.json' ,
345
+ '[]'
346
+ )
347
+ }
348
+ )
320
349
} )
321
350
322
351
describe ( 'electron:serve' , ( ) => {
Original file line number Diff line number Diff line change @@ -111,10 +111,17 @@ module.exports = (api, options) => {
111
111
fs . removeSync ( bundleOutputDir )
112
112
fs . ensureDirSync ( bundleOutputDir )
113
113
// Mock data from legacy build
114
- fs . writeFileSync (
115
- path . join ( bundleOutputDir , 'legacy-assets-index.html.json' ) ,
116
- '[]'
117
- )
114
+ const pages = options . pages || { index : '' }
115
+ Object . keys ( pages ) . forEach ( page => {
116
+ if ( pages [ page ] . fileName ) {
117
+ // If page is configured as an object, use the filename (without .html)
118
+ page = pages [ page ] . fileName . replace ( / \. h t m l $ / , '' )
119
+ }
120
+ fs . writeFileSync (
121
+ path . join ( bundleOutputDir , `legacy-assets-${ page } .html.json` ) ,
122
+ '[]'
123
+ )
124
+ } )
118
125
// Set the base url so that the app protocol is used
119
126
options . baseUrl = pluginOptions . customFileProtocol || 'app://./'
120
127
// Set publicPath as well (replaced baseUrl since @vue/cli 3.3.0)
You can’t perform that action at this time.
0 commit comments