stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.06k stars 393 forks source link

Standalone React applications #231

Open akuji1993 opened 6 years ago

akuji1993 commented 6 years ago

I have spent most of today and yesterday trying to get react-snap running in a standalone React application that hasn't been created with create-react-app. Sad to say, I'm apparently doing something wrong, since it just doesn't output anything on the site now, just an empty <div id="root"/>

I'd be really happy, if you would include a documentation regarding adding it to those projects, since we never use create-react-app as a base for our projects (too much stuff to do with the webpack.config and honestly, CRA just clutters a lot of stuff into your project that you don't need).

If documentation is too much of a hassle, which I get, can you provide any example on how to get this running in a normal React app? That would be really awesome.

stereobooster commented 6 years ago

Provide example of "normal React app". I can provide PR with working react-snap

akuji1993 commented 6 years ago

Here you go https://github.com/akuji1993/standalone-react-snap-example

akuji1993 commented 6 years ago

On https://github.com/akuji1993/standalone-react-snap-example/tree/introduce-react-snap you can find my try of integrating react-snap into the project, which results in the content being snapped and loaded, but the javascript is never served, therefore, for example, my buttons don't work on press and no JS content is executed.

stereobooster commented 6 years ago

Here you go https://github.com/akuji1993/standalone-react-snap-example/pull/1

stereobooster commented 6 years ago

So the issue is that it is not rendering. The issue is in no JS tags...

akuji1993 commented 6 years ago

Yeah, the setup I've sent you now renders the components, but the JS scripts are completely missing and aren't loaded. Sorry if my first description was unclear or misled you.

akuji1993 commented 6 years ago

Hm, wait, the example you provided in your fork / PR actually works fine. The only problem I see is this:

image

There's all the JS code loaded immediately. I got the feeling I just misunderstand something about this. Would you mind explaining why you marked it as a bug? I think I might've just confused you into thinking something's wrong, while your code is actually doing everything correctly.

stereobooster commented 6 years ago

There is a text of index.html, there are not <script> tags. Maybe you see it in 200.html, but this is different thing, this is the original index.html

akuji1993 commented 6 years ago

Ah sorry, my mistake was that i still ran npm run build on accident and in that case, it of course worked, because just no prerendering happening 🤦‍♂️

With your npm run prerender command, indeed it is not working...

stereobooster commented 5 years ago

hey @akuji1993 you have the same problem as in https://github.com/stereobooster/react-snap/issues/348#issuecomment-483069792

    <body>
-        <div id="root"/>
+        <div id="root"></div>
    </body>