I have encountered a challenge while trying to integrate the prerender-spa-plugin with Laravel 5.7 and Vue 2.6:
Error: Child compilation failed:
Entry module not found: Error: Can't resolve '/mnt/c/laragon/w ww/<project-folder>/resources/views/index.html' in '/mnt/c/laragon/ www/<project-folder>':
Error: Can't resolve '/mnt/c/laragon/www/<project-folder>/resources /views/index.html' in '/mnt/c/laragon/www/<project-folder>'
...
I was following a blog tutorial on Vue and Laravel implementation section:
Additionally, I set up my webpack.config.js file (located in the project root folder) by copying content from laravel-mix webpack.config.js along with code snippets from the tutorial:
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var PrerenderSPAPlugin = require('prerender-spa-plugin')
var Renderer = PrerenderSPAPlugin.PuppeteerRenderer
/**
* As our first step, we'll pull in the user's webpack.mix.js
* file. Based on what the user requests in that file,
* a generic config object will be constructed for us.
*/
let mix = require('./node_modules/laravel-mix/src/index');
let ComponentFactory = require('./node_modules/laravel-mix/src/components/ComponentFactory');
new ComponentFactory().installAll();
require(Mix.paths.mix());
/**
* Just in case the user needs to hook into this point
* in the build process, we'll make an announcement.
*/
Mix.dispatch('init', Mix);
/**
* Now that we know which build tasks are required by the
* user, we can dynamically create a configuration object
* for Webpack. And that's all there is to it. Simple!
*/
let WebpackConfig = require('./node_modules/laravel-mix/src/builder/WebpackConfig');
module.exports = new WebpackConfig().build();
module.exports.plugins.push(
new HtmlWebpackPlugin({
template: Mix.paths.root('resources/views/index.html'),
inject: false
})
);
module.exports.plugins.push(
new PrerenderSPAPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: [ '/' ]
})
);
The generated index.html file in the ./public folder displays the error mentioned above.