anthonygore / vue-js-laravel-multi-ssr

Source code for the article "Advanced Server-Side Rendering With Laravel & Vue: Multi-Page App"
https://vuejsdevelopers.com/2017/11/27/vue-js-laravel-server-side-rendering-router/
37 stars 6 forks source link

Dynamic/Lazy Loading for vue-router doesn't work in SSR but works in client #6

Closed sentiasa closed 5 years ago

sentiasa commented 5 years ago

I tried to write this in the blogpost but it got marked as spam :( So I'm putting it here

Hi @anthonygore. thanks for the in-depth explanation. I made everything work but dynamic component loading in router doesn't work.

This works:

import Home from '../view/Home';
export const routes = [{ path: '/', name: "Home", component: Home }]

but this doesn't:

export const routes = [{ path: '/', name: "Home", component: () => import('../views/Home.vue)' }]

and I get <div id="app" data-server-rendered="true"></div>.


and if I use this, it crashes with

export const routes = [{ path: '/', name: "Home", component: import('../views/Home.vue)' }]

Cannot find module './js/chunks/server/0.js

What do you think I am missing/doing wrong? I'd appreciate any help 🙏

sentiasa commented 5 years ago

If anyone wonders, this is how I achieved it - https://stackoverflow.com/questions/58216963/lazy-loaded-vue-router-components-dont-work-with-ssr/58297349#58297349