chrisvfritz / prerender-spa-plugin

Prerenders static HTML in a single-page application.
MIT License
7.32k stars 634 forks source link

Can not get actual content prerendered, only what's initially in index.html #62

Closed kushagharahi closed 7 years ago

kushagharahi commented 7 years ago

Project: https://github.com/kushagharahi/kushagharahi.github.io I am using vuejs2.0

I can not get the actual content of the page prerendered. All I get outputted is the original index.html w/o rendered content.

I've been scratching my head at what is wrong.

My entry point is ./src/scripts/main.js

You can see the issue in the ./dist folder. Every path's index.html is identical to ./dist/index.html. IE: ./dist/index.html is the same as ./dist/contact/index.html which is equivalent of ./src/static/index.html (the original file).

evansalter commented 7 years ago

I'm having the exact same issue. Here's a Gist containing my webpack.conf.js, index.html, and main.js. When I build, dist/index.html has the exact same content as the original index.html, except the JS bundles are injected into <head>. I generated my app from the Vue CLI webpack template.

I am completely out of ideas, so any help I can get is greatly appreciated!

csvwolf commented 7 years ago

The same problem!

evansalter commented 7 years ago

@csvwolf @kushagharahi I ended up writing my own webpack plugin that uses Nightmare.js to render the pages. It's pretty basic, but it might be worth a shot: https://github.com/esalter-va/webpack-static-site-generator

shuiRong commented 7 years ago

same problem +1

dsandrade commented 7 years ago

The same problem!

waltergalvao commented 7 years ago

Same problem :(

devmarcelosantos commented 7 years ago

Same problem!!

ghost commented 7 years ago

Hi, I don't think this is the same case. People here seem to have fully static SPAs. This is more like a version incompatibility between used components though I've not been able to repeat it. The best way for me to understand would be to share the exact repo that's not working and specify the environment.

kushagharahi commented 7 years ago

You're right @jnrdt I was tired last night and misunderstood. I deleted my comment. I apologize.

drewlustro commented 7 years ago

@kushagharahi - I downloaded your code repository and there is a key problem with it. PhantomJS hits an exception because you forgot to transpile your .js files into ES6.

Please add the following to webpack.config.js:

// ....

module: {
  rules: [
    // ... other rules
    {
      test: /\.js$/,
      loader: 'babel-loader',
      include: [
        path.join(__dirname, 'src')
      ],
      exclude: path.join(__dirname, 'node_modules')
    },
    // .. the rest of your rules
  ]
},

// ....
// rest of webpack config
// ...

I have made this change and your site prerenders without issue.

kushagharahi commented 7 years ago

@drewlustro YOU ARE BEAUTIFUL AND AMAZING. Thank you for the help. This can be closed.

drewlustro commented 7 years ago

Bahahaha. No worries my friend.

On Tue, Jun 13, 2017 at 12:46 AM, Kusha Gharahi notifications@github.com wrote:

@drewlustro https://github.com/drewlustro YOU ARE BEAUTIFUL AND AMAZING. Thank you for the help. This can be closed.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chrisvfritz/prerender-spa-plugin/issues/62#issuecomment-308005671, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL5RYuSxqR8_CGvJXeh_a4nL0_BrKn7ks5sDhQ6gaJpZM4M-4_V .

lokkomokko commented 6 years ago

@esalter-va big big thanks

vesper8 commented 6 years ago

same problem... =/

dhruvbhatia7 commented 5 years ago

same problem