Answer the question
In order to leave comments, you need to log in
How to make prerender-spa-plugin work with Laravel?
At the moment there is such code in webpack.mix.js:
const mix = require('laravel-mix');
const path = require('path')
const PrerenderSPAPlugin = require('prerender-spa-plugin')
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.sourceMaps();
if (mix.inProduction()) {
mix.version();
}
mix.webpackConfig = {
plugins: [
new PrerenderSPAPlugin({
// Required - The path to the webpack-outputted app to prerender.
staticDir: path.join(__dirname, 'dist'),
// Required - Routes to render.
routes: ['/', '/portfolio'],
})
]
}
mix.webpackConfig = {
resolve:{
plugins: [
new PrerenderSPAPlugin({
Answer the question
In order to leave comments, you need to log in
If laravel is used only as an API, and the application itself is a SPA, then it is more logical to split it into two applications - one is laravel (or even lumen) with an API, and the other is vue (vue-cli, nuxt and that's it). For mix, of course, is a good thing, but some settings are not made obviously + a lot of things are preconfigured in vue-cli and nuxt.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question