Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rafalg's avatar

Duplicate CSS link when using Vite in Laravel

When I look in my app's <head>, some of the <link rel="stylesheet" ...> tags are duplicated. The Blade view contains the first, static occurrence of the tag and then after loading the page the second one is added dynamically. Here's a (cleaned-up) example with additional information:

<!-- These two tags are static in the page source, generated by @vite(...) in a Blade view: -->
<link rel="stylesheet" href="http://localhost/build/assets/VContainer-097126a3.css" nonce="">
<script type="module" src="http://localhost/build/assets/app-950ca430.js" nonce=""></script>

<!-- This gets added dynamically after the page loads: -->
<link rel="stylesheet" href="/build/assets/VContainer-097126a3.css">

The first occurrence gets added because Vite's manifest.json file contains information that there's a dependency between app.js and VContainer.css (app.js imports some CSS, including Vuetify). So far so good.

I can't figure out why the second occurrence gets added. It's causing a problem because the second occurrence gets added after another style (skipped here for brevity) and overrides some of its rules.

I'm not sure how tags are added on the client side, whether that's handled by Laravel or Vite. Any ideas?

0 likes
3 replies
Sinnbeck's avatar

Maybe you could start sharing some code? Like your @vite() entry point

rafalg's avatar

I'll try to do that, but there's a lot of code, I'm migrating an existing application from Mix to Vite. It'll take some time to clean it up and only leave generic stuff that reproduces the issue. In the meantime I was hoping the description of the symptoms would ring a bell for someone.

Thanks for a quick response!

Sinnbeck's avatar

@rafalg you can also perhaps make a minimal reproduction of the problem in a new repo and put on github? Otherwise your best chance is that someone has had the exact same problem and seems the thread.

It is sadly very hard to help based on a description and no chance to reproduce. Especially with such a new tool :)

Please or to participate in this conversation.