nystudio107 / craft-vite

Allows the use of the Vite.js next generation frontend tooling with Craft CMS
MIT License
52 stars 16 forks source link

Can't get CSS to be included synchronously #91

Open FrDH opened 3 weeks ago

FrDH commented 3 weeks ago

Question

We're not using critical CSS (maybe some day) and want the CSS to be loaded synchronously, but for some reason setting the 2nd argument to false does not work:

{{ craft.vite.script("src/js/app.ts", false) }}

There is about 2 second FOUC every time I navigate to a new page, which is really annoying for one, but also completely destroys all (the possibility to test) view-transitions. For now, I resigned to including the CSS in a style tag before including the JS (in local environment only)

{% if craft.app.env == 'local' %}
    <link rel="stylesheet" href="{{ craft.vite.asset('src/scss/app.scss') }}">
{% endif %}
{{ craft.vite.script("src/ts/app.ts", false) }}

Any thoughts?

khalwat commented 2 weeks ago

You're seeing the FOUC only in local development when using the dev server ya?

FrDH commented 2 weeks ago

Yes, there is no FOUC if the dev server isn't running