Skip to content

VuePress integrates into Laravel

Laravel1 min read

I assume you can build VuePress standalone, so you know VuePress is compiled by node.js and it generated .html file in dist by default. We can use this feature to integrate into Laravel.

Prerequisites * You have been installed VuePress in your Laravel project.

$ yarn add -D vuepress

First of all, you have to set .vuepress/config.js, docs , the meaning is your compiled files where do you want to put it, and set your base uri.

dest: 'public/docs',
base: '/docs/',

Secondly, you need to tell Laravel where can you get its path in config/view.php

'paths' => [
base_path('public'), // for docs.

Thirdly, you can writing closure or controller putting the code.

Route::get('/docs', 'DocumentController@render');
public function render()
// Extending view can recognize `html` file.
View::addExtension('html', 'php');
// public/docs/index.html.
return view('docs.index');
© 2021 by Yish. All rights reserved.