chrisvfritz / prerender-spa-plugin

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

When assetsPublicPath is set, the page is not rendered successfully. #176

Open hfq-daipengyun opened 6 years ago

hfq-daipengyun commented 6 years ago

Vue project The value of assetsPublicPath is not '/', but '/sub/'. The page after run build is not rendered successfully, if assetsPublicPath: '/' can do it. But in my project, assetsPublicPath has to be set up. What should I do? ...

JoshTheDerf commented 6 years ago

What does your dist directory look like?

hfq-daipengyun commented 6 years ago

360 17130421737674 The file is like this: 360 17571121777758 It should be like this :(assetsPublicPath= '/', but I need ='/sub/') 360 167511058811497

hfq-daipengyun commented 6 years ago

The data is a AXIOS request

hfq-daipengyun commented 6 years ago

360 17340914588156

JoshTheDerf commented 6 years ago

I'll have to take a closer look at this one. I'm not sure how I could configure prerender-spa-plugin to respect assetsPublicPath without getting things messed up.

liangjie7 commented 6 years ago

你这个问题有解决吗

hfq-daipengyun commented 6 years ago

没有,之后考虑到项目数据变动频繁,为保证SEO实时性,去用服务器渲染了...

------------------ 原始邮件 ------------------ 发件人: "liangjie"; 发送时间: 2018年5月14日(星期一) 下午3:23 收件人: "chrisvfritz/prerender-spa-plugin"; 抄送: "hfq-daipengyun"; "Author"; 主题: Re: [chrisvfritz/prerender-spa-plugin] When assetsPublicPath is set,the page is not rendered successfully. (#176)

你这个问题有解决吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

xuexb commented 6 years ago

I also encountered the same problem. The reason is that the compiled and configured assetsPublicPath before static CDN will be wrong. There are two solutions:

  1. Bring up the static CDN before compiling
  2. Direct use of /static/ does not use stand-alone static CDN domain names
xuexb commented 6 years ago

https://github.com/chrisvfritz/prerender-spa-plugin/issues/114

Pistil-Studio commented 6 years ago

@hfq-daipengyun Hi man did you find a solution for your problem ? I have the same issue

JoshTheDerf commented 6 years ago

I haven't taken a look at this yet, but my guess is that it just needs to serve an extra static directory if assetsPublicPath is set.

Pistil-Studio commented 6 years ago

For I found another solution to publish in a subfolder, and have the prerenderer In /build/index.js conf for build : assetsRoot: '../dist', assetsSubDirectory: 'subdirectory/static', assetsPublicPath: '/subdirectory/'

In /build/webpack.prod.env.js output.publicPath: '/'

and conf for the PrerenderSPAPlugin staticDir: config.build.assetsRoot, indexPath: path.join(config.build.assetsRoot, 'index.html'), outputDir: path.join(config.build.assetsRoot, config.build.assetsPublicPath),

all prerendered website will be in '/dist/subdirectory/'

Eunknight commented 6 years ago

https://github.com/chrisvfritz/prerender-spa-plugin/issues/215#issuecomment-415942268