spatie / server-side-rendering

Server side rendering JavaScript in a PHP application
https://sebastiandedeyne.com/posts/2018/server-side-rendering-javascript-from-php
MIT License
602 stars 34 forks source link

Usage with a Webpack Dev Server #23

Closed joshhornby closed 5 years ago

joshhornby commented 5 years ago

Hi,

Has anyone managed to get this package working using Webpack Encore? I'm having issues with the dev-server as the file isn't technically created, but directly served from memory at the given URL instead. For example http://localhost:8080/build/server.js. In production it would work because you generate the files so they have a physical path on the server.

My question is has anyone got this working using a webpack dev server?

Thanks

edcoreweb commented 5 years ago

@joshhornby

I think you can fake it like this:

echo $renderer
    ->resolveEntryWith(function (string $entry): string {
        // here you can store the file on the server and return the path
        file_put_contents($path = 'my/server/path.js', file_get_contents($entry));
        return $path;
    })
    ->entry('http://localhost:8080/build/server.js')
    ->render();
rkanagaraj commented 5 years ago

The render not giving anything when I added store and router in my vue app

spatie-bot commented 5 years ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.