webpack-hot-server-middleware icon indicating copy to clipboard operation
webpack-hot-server-middleware copied to clipboard

Request: Make an example of using vue-router and vue's "createBundleRenderer"

Open dsine-de opened this issue 7 years ago • 1 comments

There is an example repository at https://github.com/vuejs/vue-hackernews-2.0 but I find it really hard to understand how webpack-hot-server-middleware would go into that. Probably some code in the hackernews example could be done with this middleware, but I'm not sure.

Also I don't get how to use Vue's JSON output (vue-ssr-client-manifest.json and vue-ssr-server-bundle.json instead of the server bundle JS output) with this middleware.

Could you prepare a minimal example setup on how to use this middleware with Vue.js and vue-router (isomorphic instantiation of a Vue "app", waiting for vue-router async hooks etc.) with express?

Probably it's much to ask and the existing examples are considered being enough for most users, but I have a hard time understanding the different plugins, Vue instantiation, SSR etc. Or is all the code in the hackernews example needed and webpack-hot-server-middleware wouldn't help in any way?

Thanks you - Vue's SSR is driving me a bit insane...

dsine-de avatar Feb 11 '18 13:02 dsine-de

@dsine-de I'm actually trying to set this up now, but running into issues with serverRenderer is not a function.

Error in question:

TypeError: serverRenderer is not a function
    at /Users/mach/Workspace/ralph/node_modules/webpack-hot-server-middleware/src/index.js:13:5
    at /Users/mach/Workspace/ralph/node_modules/webpack-hot-server-middleware/src/index.js:175:61
    at Layer.handle [as handle_request] (/Users/mach/Workspace/ralph/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/mach/Workspace/ralph/node_modules/express/lib/router/index.js:317:13)
    at /Users/mach/Workspace/ralph/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/mach/Workspace/ralph/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/mach/Workspace/ralph/node_modules/express/lib/router/index.js:275:10)
    at middleware (/Users/mach/Workspace/ralph/node_modules/webpack-hot-middleware/middleware.js:33:48)
    at Layer.handle [as handle_request] (/Users/mach/Workspace/ralph/node_modules/express/lib/router/layer.js:95:5)

However, it appears that the repo you linked gets around this problem by just watching the server side files and rebuilding as necessary. I think that with this setup, you no longer need the hot server middleware.

mach-kernel avatar May 23 '18 17:05 mach-kernel