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

app.js script chunk rendered twice #158

Open
mrkamel opened this issue Nov 13, 2019 · 5 comments · May be fixed by #160
Open

app.js script chunk rendered twice #158

mrkamel opened this issue Nov 13, 2019 · 5 comments · May be fixed by #160

Comments

@mrkamel
Copy link

mrkamel commented Nov 13, 2019

Hi, i'm using v0.6.0.

i'm facing the issue that the app.js chunk is rendered twice: renderScripts() renders the <script src="...../app.js" defer> into the index.ssr.html and the htmlPlugin included in vue-cli-plugin-ssr renders <script src=".../app.js"> as well into the markup, such that it gets loaded twice by the browser and vue gets hydrated twice as well.

<body>
   ....
    <script src="/de/suche/app.js" defer></script>
   <script type="text/javascript" src="/de/suche/app.js"></script>
</body>

https://webpack.js.org/plugins/html-webpack-plugin/ states:

The plugin will generate an HTML5 file for you that includes all your webpack bundles in the body using script tags.

The specific code is: https://github.com/Akryum/vue-cli-plugin-ssr/blob/master/lib/webpack.js#L54
If i add chunks: [] there, it works fine again, such that it is no longer rendered twice.

@mrkamel mrkamel changed the title app.js rendered twice app.js script chunk rendered twice Nov 14, 2019
@mrkamel
Copy link
Author

mrkamel commented Nov 14, 2019

Not surprisingly, this commit introduced the issue: f9d4093

@ralf57
Copy link

ralf57 commented Nov 19, 2019

@Akryum
I am experiencing the same issue.
It should be fixed ASAP since it also impacts performance.

@ralf57 ralf57 linked a pull request Nov 19, 2019 that will close this issue
@ralf57
Copy link

ralf57 commented Nov 19, 2019

Since it's apparently not possible to alter the configuration of the html plugin in vue.config.js, I've created #160

@RastislavHudak
Copy link

Since it's apparently not possible to alter the configuration of the html plugin in vue.config.js, I've created #160

You saved my day!

Just for reference, it also seemed to be causing following errors for me (both came after update to 0.6.0):

  • vue would complain I mutate store state outside of mutation handles (which wasn't the case)
  • router navigation would push to history twice

When I applied the fix for #160 problems disappeared.

@mrkamel
Copy link
Author

mrkamel commented Dec 6, 2019

Since it's apparently not possible to alter the configuration of the html plugin in vue.config.js, I've created #160

actually it's possible to fix it by only changing vue.config.js

  chainWebpack: (config) => {
    // https://github.com/Akryum/vue-cli-plugin-ssr/issues/158
    const htmlSsrPlugin = config.plugins.get('html-ssr')

    if (htmlSsrPlugin) {
      htmlSsrPlugin.store.get('args')[0].chunks = []
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants