Closed acalvino4 closed 2 years ago
Alright, after digging into the source code, I see that my src/ts/index.ts
key in manifest.json
should have a css
key that refers to the style.css
asset in order for that asset to be loaded in my template. This seems to not be a bug with this plugin, but some failure of my vite build process to generate that key in manifest.json
.
What version of Vite are you running?
vite 3.0.3. Though it was happening with 2.9.5 as well.
I found that if I have build.cssCodeSplit: true
(was previously false), then all works well! So I can at least move forward, though I am curious why disabling code splitting changes the manifest.json in that particular way.
That is pretty interesting. I do plan to add a way to manually include CSS tags for people who really want to do that, which is something that support was only added for in Vite 3.x
What is the default setting for build.cssCodeSplit
? I'm assuming it is true
?
Yes, the default is true. I had manually set it to false, but I would have expected the only difference to be that all css is never split into multiple files, not a change in the manifest pattern.
https://vitejs.dev/config/build-options.html#build-csscodesplit
Describe the bug
When I include
{{ craft.vite.script(src/ts/index.ts) }}
in my twig template, and dev server is not running, no<link rel="stylesheet" ...>
tag is generated in my markup.To reproduce
Steps to reproduce the behaviour:
npm run build
- assets and manifest are generated correctly{{ craft.vite.script(src/ts/index.ts) }}
in page templatecraft.vite.script
tagExpected behaviour
scripts and styles are linked and loaded as described in docs: https://nystudio107.com/docs/vite/#production
Actual behavior
scripts are loaded and executed (no console errors), but style tag does not appear in page markup
Code Examples
The rendered
head
code:Minimal template example:
My
index.ts
does include an import of the cssAnd here's my
manifest.json
Vite is generating my minified, processed css files correctly, hence why I think this is on the Plugin side.
Versions