Closed acouch closed 5 years ago
You can write one yourself:
#!/usr/bin/env node
const { run } = require("react-snap");
run({
publicPath: "/",
include: JSON.parse(process.argv[2])
}).catch(error => {
console.error(error);
process.exit(1);
});
The problem is following at the moment it doesn't have any arguments, as soon as I will add at least one, people will ask for the rest, in the end I will need to support all of them. As well people ask to support alternative config formats, like .react-snap.js
.
Maybe there is another library more suited for this.
Maybe react-static?
Thanks for the quick response and awesome library. I'll close this since you provided an option and explanation.
Feature Request
Is your feature request related to a problem? Please describe. I'd like to be able to pass all of the routes to react snap programmatically. This way we can be sure what routes are rendered and not rely on the crawling of links. Our site has a large search page so there is not a simple way for the crawler to know to click through all of the pages.
Additionally it would be nice to be able to use react-snap to update only specific routes. If a single page gets updated in our backend we'd like to pass that on to react snap and only update a single page. Or if we've done a large operation we'd like to re-render a part of the site.
This is similar but not the same as: https://github.com/stereobooster/react-snap/pull/305
Describe the solution you'd like
I'd like to be able to call something like
./run.js --include=["/blog/*]]
or./run.js --include=[ARRAY OF ROUTES]
where "ARRAY OF ROUTES" is a json array generated by our backend.Describe alternatives you've considered We've thought about generating a sitemap.html that the we would write to and include in the
package.json
file.I think this could be somewhat unobtrusively added by looking for cli arguments in
run.js
and checking to see if they are part of the default arguments object.I'd be willing to create a PR w/ tests etc.
Maybe there is another library more suited for this.
I'm using create-react-app FWIW.