Skip to content

Commit 8e20be6

Browse files
committed
Also check for old plugin options on build command
1 parent 70d9da6 commit 8e20be6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

generator/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff 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}`);

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ts-check
2-
const { exists } = require("fs");
2+
const { exists, readFileSync } = require("fs");
33
const path = require("path");
44

55
const PrerenderSPAPlugin = require("prerender-spa-plugin");
@@ -13,7 +13,16 @@ module.exports = (api, projectOptions) => {
1313

1414
function 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
}

0 commit comments

Comments
 (0)