Open jeanpco opened 5 years ago
I'm officially sad
Hi @jeanpco. Thought I commented on this already, but apparently not. I appreciate you going through all the effort to include the detail you've provided.
The issue appears to be that you have not configured prerender-spa-plugin to listen for the render-event
event.
Try adding the following.
webpack.config.js
new PrerenderSpaPlugin({
staticDir: path.resolve(__dirname, './dist'),
// Add this section to tell prerender to render when "render-event" is fired.
renderer: new PrerenderSpaPlugin.PuppeteerRenderer({
renderAfterDocumentEvent: 'render-event'
}),
routes: [
'/',
'/about',
'/contact',
'/gallery',
'/exhibits',
'/asia',
'/beautiful-darkness',
'/forest',
'/placelessness',
'/the-glow',
'/rediscover-the-sublime',
'/inner-outer-worlds',
'/the-world-within'
],
postProcessHtml: function (context) {
var titles = {
'/': 'Home',
'/about': 'About',
'/contact': 'Contact',
'/gallery': 'Gallery',
'/exhibits': 'Exhibits',
'/asia': 'Asia',
'/beautiful-darkness': 'Beautiful Darkness',
'/forest': 'Forest',
'/placelessness': 'Placelessness',
'/the-glow': 'The Glow',
'/rediscover-the-sublime': 'Rediscover The Sublime',
'/inner-outer-worlds': 'Inner Outer Worlds',
'/the-world-within': 'The World Within'
}
return context.html.replace(
/<title>[^<]*<\/title>/i,
'<title>' + titles[context.route] + '</title>'
)
}
}),
That should be all you need.
Thank you so much! I will give it a shot!
Humm.. Seems like I'm still getting the same issue.
However, looking at the doc https://github.com/chrisvfritz/prerender-spa-plugin for renderAfterDcoumentEvent. It says:
// Optional - Wait to render until the specified event is dispatched on the document.
// eg, with `document.dispatchEvent(new Event('custom-render-trigger'))`
renderAfterDocumentEvent: 'custom-render-trigger', ( 'render-event' ) in our case.
But where do we actually dispatch that render-event?
My webpack.config now looks like this.
var path = require('path')
var webpack = require('webpack')
var PrerenderSpaPlugin = require('prerender-spa-plugin') // Here
var HtmlWebpackPlugin = require('html-webpack-plugin') // And here
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new HtmlWebpackPlugin({
template: 'index.html',
filename: path.resolve(__dirname, 'dist/index.html')
}),
new PrerenderSpaPlugin({
staticDir: path.resolve(__dirname, './dist'),
renderer: new PrerenderSpaPlugin.PuppeteerRenderer({
renderAfterDocumentEvent: 'render-event'
}),
routes: [
'/',
'/about',
'/contact',
'/gallery',
'/exhibits',
'/asia',
'/beautiful-darkness',
'/forest',
'/placelessness',
'/the-glow',
'/rediscover-the-sublime',
'/inner-outer-worlds',
'/the-world-within'
],
postProcessHtml: function (context) {
var titles = {
'/': 'Home',
'/about': 'About',
'/contact': 'Contact',
'/gallery': 'Gallery',
'/exhibits': 'Exhibits',
'/asia': 'Asia',
'/beautiful-darkness': 'Beautiful Darkness',
'/forest': 'Forest',
'/placelessness': 'Placelessness',
'/the-glow': 'The Glow',
'/rediscover-the-sublime': 'Rediscover The Sublime',
'/inner-outer-worlds': 'Inner Outer Worlds',
'/the-world-within': 'The World Within'
}
return context.html.replace(
/<title>[^<]*<\/title>/i,
'<title>' + titles[context.route] + '</title>'
)
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
Thank you!
It looks like you're already dispatching that event in your main component's mounted hook. If not, you'll need to do so there.
On Tue, Jun 4, 2019, 7:21 AM Jean-P Firme de design web < notifications@github.com> wrote:
Humm.. Seems like I'm still getting the same issue.
However, looking at the doc https://github.com/chrisvfritz/prerender-spa-plugin for renderAfterDcoumentEvent. It says:
// Optional - Wait to render until the specified event is dispatched on the document. // eg, with
document.dispatchEvent(new Event('custom-render-trigger'))
renderAfterDocumentEvent: 'custom-render-trigger', ( 'render-event' ) in our case.But where do we actually dispatch that render-event?
My webpack.config now looks like this.
var path = require('path') var webpack = require('webpack') var PrerenderSpaPlugin = require('prerender-spa-plugin') // Here var HtmlWebpackPlugin = require('html-webpack-plugin') // And here
module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, './dist'), publicPath: '/', filename: 'build.js' }, module: { rules: [ { test: /.css$/, use: [ 'vue-style-loader', 'css-loader' ], }, { test: /.vue$/, loader: 'vue-loader', options: { loaders: { } // other vue-loader options go here } }, { test: /.js$/, loader: 'babel-loader', exclude: /node_modules/ }, { test: /.(png|jpg|gif|svg)$/, loader: 'file-loader', options: { name: '[name].[ext]?[hash]' } } ] }, resolve: { alias: { 'vue$': 'vue/dist/vue.esm.js' }, extensions: ['*', '.js', '.vue', '.json'] }, devServer: { historyApiFallback: true, noInfo: true, overlay: true }, performance: { hints: false }, devtool: '#eval-source-map' }
if (process.env.NODE_ENV === 'production') { module.exports.devtool = '#source-map' // http://vue-loader.vuejs.org/en/workflow/production.html module.exports.plugins = (module.exports.plugins || []).concat([ new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"' } }), new HtmlWebpackPlugin({ template: 'index.html', filename: path.resolve(__dirname, 'dist/index.html') }),
new PrerenderSpaPlugin({ staticDir: path.resolve(__dirname, './dist'), renderer: new PrerenderSpaPlugin.PuppeteerRenderer({ renderAfterDocumentEvent: 'render-event' }), routes: [ '/', '/about', '/contact', '/gallery', '/exhibits', '/asia', '/beautiful-darkness', '/forest', '/placelessness', '/the-glow', '/rediscover-the-sublime', '/inner-outer-worlds', '/the-world-within' ], postProcessHtml: function (context) { var titles = { '/': 'Home', '/about': 'About', '/contact': 'Contact', '/gallery': 'Gallery', '/exhibits': 'Exhibits', '/asia': 'Asia', '/beautiful-darkness': 'Beautiful Darkness', '/forest': 'Forest', '/placelessness': 'Placelessness', '/the-glow': 'The Glow', '/rediscover-the-sublime': 'Rediscover The Sublime', '/inner-outer-worlds': 'Inner Outer Worlds', '/the-world-within': 'The World Within' } return context.html.replace( /<title>[^<]*<\/title>/i, '<title>' + titles[context.route] + '</title>' ) } }), new webpack.optimize.UglifyJsPlugin({ sourceMap: true, compress: { warnings: false } }), new webpack.LoaderOptionsPlugin({ minimize: true })
]) }
Thank you!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chrisvfritz/prerender-spa-plugin/issues/318?email_source=notifications&email_token=ABMW76ZQPOT5VLY2IW2FDELPYZF3VA5CNFSM4HN2SQSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW4H6KA#issuecomment-498630440, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMW764JOEY7UVY24BQ6UI3PYZF3VANCNFSM4HN2SQSA .
First of I just want to say that I've read this thread but could spot the relevant info to my problem. https://github.com/chrisvfritz/prerender-spa-plugin/issues/31.
Question breakdown: 1 - Explanation of the problem 2 - Example of what's not working 3 - Project files with relevant code
My problem is the following:
The JS and other dependencies such as
Vuelidate
andElementUI
does not seem to work, but I can log stuff to the console and do stuff inmounted()
like such:I'm getting this odd warning from VSCode and I'm not sure what to do with it, but I'm adding a screenshot in case it'd relevant.
Other than the stuff inside
mounted()
, nothing seems to work. The following are not firing at all:From
package.json
From main.js
from index.html
From
webpack.config.js
my importsFrom
process.env.NODE_ENV === 'production'
I'm also attaching the entire project as a ZIP here. I have removed all the assets so I can upload this.
coma.zip
Thank you so much in advance. Hopefully someone known!