question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

app.js script chunk rendered twice

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

31reactions
mrkamelcommented, 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 = []
    }
  }
0reactions
RastislavHudakcommented, Dec 2, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my Remix app rendering twice without any outlets?
My Remix app seems to be rendered twice, even when removing all routes and components. I'm a little unsure as to why.
Read more >
Developers - app.js script chunk rendered twice - - Bountysource
Hi, i'm using v0.6.0. i'm facing the issue that the app.js chunk is rendered twice: renderScripts() renders the into the index.ssr.html and the...
Read more >
All .js & .css (.vm) rendered twice on search issue page
In this app, we have added a web-panel on Jira issue details page. We have noticed our page is rendered twice on the...
Read more >
React Components rendered twice — any way to fix this?
The reason why this happens is an intentional feature of the React.StrictMode . It only happens in development mode and should help to...
Read more >
Synchronizing with Effects - React Docs
Every time your component renders, React will update the screen and then run the code inside useEffect . In other words, useEffect “delays”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found