#Support `<style>` or `<script>` with Vite tag
1 messages · Page 1 of 1 (latest)
The correct <style> and <script> tags will be automatically injected if you use the @vite Blade directive.
Are you sure ?
Vite can actually output HTML tag to load files.
What?
But from my understanding of the documentation it can not output the content of an asset inline.
Why would you want to?
Like so
<style>
// the critical.css file content goes here...
</style>
To load some js and css very early
So add the style tag and paste the CSS
Why would you need to have inlined CSS as part of a Vite build process
I imagine Lighthouse metrics or something, where they’ve been given an advisory to move “critical” CSS to load as soon as possible.
How you would split that out with Vite, I don’t know, though.
<html>
<head>
<title>{{ $title }}</title>
<style>
// super critical css here
</style>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
{{ $slot }}
</body>
</html>
you're welcome
I want to be able to bundle my css and js with Vite
And for some assets decide to inline them or not
Copy paste... really...
What are you even saying.
You have some CSS that's inside some file already, which is being processed by Vite.
You want that file to be thrown into a style tag inside your HTML markup, instead of being a separately loaded file.
Simply take that CSS in a file, to be processed by Vite, and copy it into the template.
It's a one time practice.
Or explain why you need this processed by Vite.
I'm using SASS for CSS and TS for JS
Plus I want my source file all in the same place
Anyway that's ok
If nobody is interested in this feature, their no point to share it
Share what? You asked for it
" For exemple how can I output the following from a critical.css file :"
Yep read my message from the beginning is better
I already did, you're asking how to achieve something. Now you're saying there's no point in sharing it if nobody is interested. I am asking what you want to share, when it's you who's asking for it
Jorqensen
You're making it sound like you have the solution already
Have a good evening
If you're just trying to have a chat about something, but don't need help, then you've posted in the wrong channel.
Yeah you're asking how to do something and then saying you didn't