Laravel-mix: inline css

Created on 30 Aug 2017  路  5Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: #.#.# 1.4.2

There is a way to use again inline css for webpack?
I need it for inline in some blade mails

Thanks :)

Most helpful comment

For googlers! Bonobomagno's method does not work. You should use this code:

<style> {!! readfile(public_path('css/app.css')) !!} </style>

All 5 comments

Mix will create a dedicated output file for your CSS. You can inline it with PHP if you want.

you suggest to use something like ?
{{readfile(mix('/public/css/mail.css')}}

I think that still a feature request can be needed.

For googlers! Bonobomagno's method does not work. You should use this code:

<style> {!! readfile(public_path('css/app.css')) !!} </style>

For googlers - mezhevikin's answer doesn't work properly either. It will output the number of bytes read, which you don't want. Use this code:
{!! file_get_contents(public_path('css/app.css')) !!}

Hi @slavicd ! You are right. Now my old method does not work.
However, I would recommend using readfile instead of file_get_contents, because it does not read data into RAM.
Just use php directly in your blade template.

<style>
     <?php readfile(public_path('css/app.css')) ?>
</style>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rderimay picture rderimay  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments

stefensuhat picture stefensuhat  路  3Comments

rlewkowicz picture rlewkowicz  路  3Comments

mstralka picture mstralka  路  3Comments