GithubHelp home page GithubHelp logo

Comments (8)

geelen avatar geelen commented on June 2, 2024 1

I don't mind it, but to be honest, a bit of config isn't maybe too bad:

/* package.json */
{
  ...,
  "react-snapshot": [
    "/",
    "/form?with=params"
  ]
}

That way at least each line is nicely tracked by version control...

from react-snapshot.

geelen avatar geelen commented on June 2, 2024

Yeah I think that's common enough. I'm thinking that "zero configuration" should maybe mean "no configuration beyond command-line args". So you could do

react-snapshot / /form?with=params

Alternatively, we could look for something in package.json but... that feels unnecessary

from react-snapshot.

jonathaningram avatar jonathaningram commented on June 2, 2024

For this type of configuration, are command line args a bit "ugly" in that usually react-snapshot is called inside a package.json script?

"build": "react-scripts build && react-snapshot / /form?with=params"

Which looks like your pushing knowledge of your routes upstream (i.e. out of src up into package.json).

Maybe there's smarter ways / tricks to avoid putting it straight in package.json - e.g. make a local bin/react-snapshot:

#!/bin/bash
react-snapshot / /form?with=params

And then the package.json script becomes:

"build": "react-scripts build && bin/react-snapshot"

Would you solve it like that, or does it not really bother you putting the cmd line args in package.json?

from react-snapshot.

jonathaningram avatar jonathaningram commented on June 2, 2024

Yeah that would be nicer, especially with, say, 10 paths.

Not that this affects me, but being hard-coded in package.json means that you can't have extra paths that are unknown at compile time (e.g. extra paths created from an array of products).

Not sure if that's something to consider.

from react-snapshot.

geelen avatar geelen commented on June 2, 2024

Yeah but those should be found by crawling your product index file, right?

from react-snapshot.

jonathaningram avatar jonathaningram commented on June 2, 2024

Yep it was a contrived example of a set of paths that might need to be generated at runtime based on other data - I don't actually have that case.

from react-snapshot.

jonathaningram avatar jonathaningram commented on June 2, 2024

Maybe a more realistic example would be if you had paths like /module1/form, /module2/form, ..., /moduleN/form (say these are forms that you embed for a set of N teaching modules)

If N was unknown at compile time then you couldn't put these paths in package.json. Even if N was known, if it was equal to 100 or 1000, then you'd have a massive package.json that could be solved by the extra path config coming from a JS file using a loop.

Anyway, again, I don't need this for my use case so I don't want to overcomplicate the discussion - it just depends how flexible you'd like this configuration to be.

from react-snapshot.

geelen avatar geelen commented on June 2, 2024

Sorry for dropping this for a while. I think in the case you describe, it probably makes more sense to make like a index page for all the URLs you can't otherwise reach, call it like __index.html or something. If you put a hidden link on your homepage, or point react-snapshot at it directly in package.json, the crawler will find it and cache all those routes.

I think that's better than having an executable config.

from react-snapshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.