You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I need to add css to my control panel, and want it to work whether I've built my production css or not, whether I'm running my dev server or not, and want it to work with hash suffixes that may change. Hence, I need it to work with my vite setup.
I can easily do this with js/ts using a custom module event like
However, if I try to load a css file that way, I get this console error in the browser
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/css". Strict MIME type checking is enforced for module scripts per HTML spec.
since vite->register outputs a script tag.
Describe the solution you would like
The ideal solution would be modifying the register function to detect what type of resource is being registered and output the appropriate tag. An alternative function such as registerAsset() is completely fine by me as well.
Describe alternatives you have considered
There of course is the cp css plugin, but that on it's own doesn't deal well with the cache-busting hashes, and doesn't allow access to css via the dev server / without building.
I could just use the register function that this plugin already provides to register js, then load my css from there. That's obviously unideal since it introduces extraneous intermediate files, and is the kind of annoyance that led to this issue.
I could probably figure out a way to combine Craft::$app->getView()->registerCssFile() with Vite::getInstance()?->vite->asset(), and that is my backup plan, but it's an undesirable increase in complexity.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I need to add css to my control panel, and want it to work whether I've built my production css or not, whether I'm running my dev server or not, and want it to work with hash suffixes that may change. Hence, I need it to work with my vite setup.
I can easily do this with js/ts using a custom module event like
However, if I try to load a css file that way, I get this console error in the browser
since
vite->register
outputs a script tag.Describe the solution you would like
The ideal solution would be modifying the register function to detect what type of resource is being registered and output the appropriate tag. An alternative function such as
registerAsset()
is completely fine by me as well.Describe alternatives you have considered
register
function that this plugin already provides to register js, then load my css from there. That's obviously unideal since it introduces extraneous intermediate files, and is the kind of annoyance that led to this issue.Craft::$app->getView()->registerCssFile()
withVite::getInstance()?->vite->asset()
, and that is my backup plan, but it's an undesirable increase in complexity.The text was updated successfully, but these errors were encountered: