quanghung97/laravel-v8js-ssr-vue

Server side rendering JavaScript with Vuejs in your Laravel application V8js

v1.0 2019-06-01 04:20 UTC

README

Dependency

You must install V8js extension on PHP, If you using docker you can using php-fpm

https://github.com/quanghung97/laradock/tree/master/php-fpm

Installation

1- composer require quanghung97/laravel-v8js-ssr-vue.

2- php artisan vendor:publish --provider="Quanghung97\laravelV8jsSsrVue\LaravelSsrV8jsVueServiceProvider"

3- add config your webpack.mix.js below

mix.js('resources/js/client.js', 'public/js')
    .js('resources/js/server.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

This package will create component AppSSR.vue AppSSR.js client.js server.js ssr.blade.php

4- npm install vue-server-renderer --save

5- npm run dev

6- please change or remove some routes like '/' in routes/web.php

Example:

Route::get('/', function () { // change '/' to '/something'
    return view('welcome');
});

now you can go yourdomain and view page source have data-server-rendered="true"