-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Inline CSS Loading Fails with Vite 5 #24
Comments
Appreciate the issue! I think: $filenameParts = preg_split("/[.-]/", $filename); Might be problematic if the file name has a |
Yeah, you're right. The quick and dirty fix was a stopgap for my scenario. Ideally, if possible, checking which version of Vite is being used and then deciding whether to split file names at dots, or just at the last dash (for Vite 5) based on that information, could be a more stable solution. Alternatively, instead of checking the version, checking if there are dots in the filename and, if not, splitting at the last dash could be another approach. |
Addressed in the above commits. |
Describe the bug
When using Vite 5, the function
{{ craft.vite.inline(craft.vite.entry('emails.css')) }}
fails to return any output, indicating a significant issue with inline CSS loading. The core of the problem lies within theextractEntry
function inmanifestHelper.php
, which is required to delve deeper due to changes in how CSS files are represented inmanifest.json
in Vite 5. The malfunction occurs because thestyleKey
is not correctly retrieved. This is due to thefilenameWithoutHash
function not functioning correctly, as it only searches for dots in filenames, ignoring dashes. This specific issue traces back to the transition from Vite 3 to Vite 4, where the separator in filenames changed from dots to dashes. However, the repercussions of this change only became apparent with the introduction of Vite 5, due to adjustments in the manifest file structure and the handling of CSS files. A workaround involves modifying line 300 inManifestHelper.php
from$filenameParts = explode('.', $filename);
to$filenameParts = preg_split("/[.-]/", $filename);
, which addresses the issue and allows the CSS fromemail.css
to be correctly inlined.To reproduce
To reproduce the behavior, follow these steps:
{{ craft.vite.inline(craft.vite.entry('emails.css')) }}
.Expected behaviour
The expected behavior is for the CSS from
emails.css
to be correctly inlined when using the{{ craft.vite.inline(craft.vite.entry('emails.css')) }}
function in Craft CMS with Vite 5.Screenshots
N/A
Versions
The text was updated successfully, but these errors were encountered: