File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,6 @@ module.exports = (api, options) => {
22 api . onCreateComplete ( ( ) => {
33 const fs = require ( "fs" ) ;
44
5- fs . exists ( "./.prerender-spa.json" , exists => {
6- if ( exists ) {
7- Object . assign ( options , JSON . parse ( fs . readFileSync ( "./.prerender-spa.json" ) ) ) ;
8- fs . unlinkSync ( "./.prerender-spa.json" ) ;
9- }
10- } ) ;
11-
125 if ( options . useRenderEvent ) {
136 const ext = api . hasPlugin ( "typescript" ) ? "ts" : "js" ;
147 const mainPath = api . resolve ( `./src/main.${ ext } ` ) ;
Original file line number Diff line number Diff line change 11//@ts -check
2- const { exists } = require ( "fs" ) ;
2+ const { exists, readFileSync } = require ( "fs" ) ;
33const path = require ( "path" ) ;
44
55const PrerenderSPAPlugin = require ( "prerender-spa-plugin" ) ;
@@ -13,7 +13,16 @@ module.exports = (api, projectOptions) => {
1313
1414function chain ( api , projectOptions ) {
1515 return config => {
16- const options = pickle ( projectOptions , CONFIG_OBJ_PATH ) ;
16+ let options ;
17+ try {
18+ options = pickle ( projectOptions , CONFIG_OBJ_PATH ) ;
19+ } catch {
20+ exists ( "./.prerender-spa.json" , exists => {
21+ if ( exists ) {
22+ Object . assign ( options , JSON . parse ( readFileSync ( "./.prerender-spa.json" ) . toString ( "utf-8" ) ) ) ;
23+ }
24+ } ) ;
25+ }
1726 if ( options . onlyProduction && process . env . NODE_ENV !== "production" ) {
1827 return ;
1928 }
You can’t perform that action at this time.
0 commit comments