Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serve error after installed this plugin #16

Closed
CrystalXuLi opened this issue Jan 3, 2019 · 13 comments
Closed

serve error after installed this plugin #16

CrystalXuLi opened this issue Jan 3, 2019 · 13 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@CrystalXuLi
Copy link

Describe the bug
this is a blank project init by vue ui, include vue-router, after install this plugin, I got an error when serve it, I haven't change any code …

To Reproduce
Steps to reproduce the behavior:

  1. vue ui
  2. create project
  3. choose vue-router
  4. search plugin vue-cli-plugin-prerender-spa and install it
  5. task -> serve

Screenshots
image

@SolarLiner SolarLiner added bug Something isn't working question Further information is requested labels Jan 3, 2019
@SolarLiner
Copy link
Owner

Sorry, I can't reproduce. Serving works fine - besides I tested the use-case before releasing version 1.1.0.

Which version of the plugin are you using?

@savander
Copy link

savander commented Jan 3, 2019

I also have problem with serving project. With a bit different error. Actually, I'm using only vue project with babel and preprocessor. It's a blank project, without plugin it serves just fine. After adding plugin, it tells me that:

98% after emitting PrerenderSPAPluginError: ENOENT: no such file or directory, stat '<path>\dist\app.html'.
Also, because of installing this plugin it cause to print one more error:

URIError: Failed to decode param '/%3C%=%20BASE_URL%20%%3Efavicon.ico'
at decodeURIComponent (<anonymous>)
                                  at decode_param (<path>\development\node_modules\express\lib\router\layer.js:172:12)
                                  at Layer.match (<path>\development\node_modules\express\lib\router\layer.js:123:27)
                                  at matchLayer (<path>\development\node_modules\express\lib\router\index.js:574:18)
                                  at next (<path>\development\node_modules\express\lib\router\index.js:220:15)
                                  at expressInit (<path>\development\node_modules\express\lib\middleware\init.js:40:5)
                                  at Layer.handle [as handle_request] (<path>\development\node_modules\express\lib\router\layer.js:95:5)
                                  at trim_prefix (<path>\development\node_modules\express\lib\router\index.js:317:13)
                                  at <path>\development\node_modules\express\lib\router\index.js:284:7
                                  at Function.process_params (<path>\development\node_modules\express\lib\router\index.js:335:12)
                                  at next (<path>\development\node_modules\express\lib\router\index.js:275:10)
                                  at query (<path>\development\node_modules\express\lib\middleware\query.js:45:5)
                                  at Layer.handle [as handle_request] (<path>\development\node_modules\express\lib\router\layer.js:95:5)
                                  at trim_prefix (<path>\development\node_modules\express\lib\router\index.js:317:13)
                                  at <path>\development\node_modules\express\lib\router\index.js:284:7
                                  at Function.process_params (<path>\development\node_modules\express\lib\router\index.js:335:12)

It's default plugin config:

module.exports = {
  pluginOptions: {
    prerenderSpa: {
      registry: undefined,
      renderRoutes: [
        '/'
      ],
      useRenderEvent: true,
      headless: true,
      onlyProduction: true
    }
  }
}

plugin version: 1.1.0

I forgot to tell, that serve generally runs, but website is blank white. Just nothing.

@CrystalXuLi
Copy link
Author

@SolarLiner I'm using version 1.1.0 too, I've tried many times and got same error.
Here's my inited project, https://github.com/CrystalXuLi/prerender-spa-test
Please help me to find out where I'm wrong (。・ω・。)

@SolarLiner
Copy link
Owner

Okay, I can reproduce - I didn't see it printing the error as the console gets cleared after the dev build completes. The thing is that the plugin shouldn't even be loaded for development builds and the development server.

I'll look into it!

@SolarLiner SolarLiner removed the question Further information is requested label Jan 4, 2019
@SolarLiner SolarLiner self-assigned this Jan 4, 2019
@SolarLiner SolarLiner modified the milestone: 1.2.0 Jan 4, 2019
@SolarLiner
Copy link
Owner

I've solved the no such file or directory: app.html issue which led to a blank page on development builds; however now if you use pre-rendering while in development the build never finishes.

Maybe I should just hardcode-disable it if running serve ...

@nikmel2803
Copy link

I have the same problem: development server does not work correctly (I see only blank page).
My code: https://github.com/codex-team/hawk.so/tree/develop/frontend
When can we expect a bug fix? ;D

@SolarLiner
Copy link
Owner

SolarLiner commented Jan 5, 2019

I've solved the blank page issue in the hotfix branch - but that uncovered another bug that I need to fix whith Puppeteer enabled in serve mode.

@SolarLiner SolarLiner added the help wanted Extra attention is needed label Jan 6, 2019
@savander
Copy link

savander commented Jan 8, 2019

It looks, like if you set onlyProduction: false, you have to run npm run build before serve, so PreRender will find proper index.html. I think, it should find for that index.html in different place. I'm not sure, how serve works.

@SolarLiner
Copy link
Owner

Ah, that makes a lot of sense. serve command works after a build, and live reload still performs as expected.

@savander This is really useful information, thanks for sharing!

@bounoable
Copy link

bounoable commented Jan 13, 2019

Don't really know if that helps, but I solved the blank page problem by manually changing the webpack config in the vue.config.js

{
    chainWebpack: config => {
        if (process.env.NODE_ENV !== 'production') {
            config.plugin('html').tap(args => {
                delete args[0].filename
                return args
            })
        }
    },
}

@SolarLiner
Copy link
Owner

That is the fix I applied in the feature branch. However it still breaks with onlyProduction: false, though.

I'll be releasing the fix with a notice that onlyProduction will be forced to true while the bug is fixed.

SolarLiner added a commit that referenced this issue Jan 13, 2019
Hotfix release 1.1.1

- Workaround blank page on development builds by force disabling the plugin on dev builds (#16)
@SolarLiner SolarLiner added this to the 1.1 hotfixes milestone Jan 17, 2019
@lcat
Copy link

lcat commented Aug 23, 2019

return Object.assign(options, { onlyProduction: true }); // Force disable on development build, workaround for #16

@SolarLiner This code will assign onlyProduction Always true.

If I have test or beta env. it's not work

@SolarLiner
Copy link
Owner

Yes; this is a workaround for this very issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants