Download the PHP package campaigningbureau/critical-laravel-routes without Composer
On this page you can find all versions of the php package campaigningbureau/critical-laravel-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download campaigningbureau/critical-laravel-routes
More information about campaigningbureau/critical-laravel-routes
Files in campaigningbureau/critical-laravel-routes
Package critical-laravel-routes
Short Description Automatically create and link Critical CSS for static routes in Laravel projects
License MIT
Informations about the package critical-laravel-routes
Critical Laravel Routes
Automatically create and link Critical CSS for static routes.
Supports Laravel 7.*
Installation
Just require the package via composer:
The package gets automatically discovered by Laravel.
Usage
-
All static routes, that should use critical css, need to be named and have a
critical
attribute set totrue
: -
Generate the JSON that contains all critical routes:
-
The generated file needs to be required in the webpack.mix.js and set as
urls
when creating the critical css:When generating the css, one css file per defined route is created and saved.
-
Automatically import the content of the critical css file (if it exists for the route) in the blade template as inline styles:
Alternatively, the critical css file can be linked with:
This can be used safely vor every existing route, so it is best to put it in the base layout. If no critical css file is found for a route, nothing is displayed.
Configuration
The config can be changed by publishing the configuration file:
It is possible to configure the name of the generated JSON file and the suffix for the critical css filess.