#Support `<style>` or `<script>` with Vite tag

1 messages · Page 1 of 1 (latest)

rustic estuary
#

Hi there 🙂
I'm maybe wrong, by it does not seems possible to output a <style> or <script> from a Vite entry right ?
For exemple how can I output the following from a critical.css file :

<style>
// the critical.css file content goes here...
</style>
worldly pier
#

The correct <style> and <script> tags will be automatically injected if you use the @vite Blade directive.

rustic estuary
#

Are you sure ?
Vite can actually output HTML tag to load files.

worldly pier
#

What?

rustic estuary
#

But from my understanding of the documentation it can not output the content of an asset inline.

worldly pier
#

Why would you want to?

rustic estuary
#

Exactly what I said 🙂

#

Output the content inline

true otter
#

Why do you need it inline?

#

whats the point

rustic estuary
#

Like so

<style>
// the critical.css file content goes here...
</style>
#

To load some js and css very early

vale veldt
#

So add the style tag and paste the CSS

#

Why would you need to have inlined CSS as part of a Vite build process

worldly pier
#

How you would split that out with Vite, I don’t know, though.

vale veldt
#
<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

rustic estuary
#

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...

vale veldt
#

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.

rustic estuary
#

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

vale veldt
#

Share what? You asked for it

rustic estuary
#

lol

#

I ask for nothing

#

I asked if it's already possible

vale veldt
#

" For exemple how can I output the following from a critical.css file :"

rustic estuary
#

Yep read my message from the beginning is better

vale veldt
#

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

rustic estuary
#

Jorqensen

vale veldt
#

You're making it sound like you have the solution already

rustic estuary
#

Have a good evening

vale veldt
#

If you're just trying to have a chat about something, but don't need help, then you've posted in the wrong channel.

rustic estuary
#

Just read my first message again 😉

#

Good bye

vale veldt
#

Yeah you're asking how to do something and then saying you didn't