forked from kalfheim/critical-css
-
Notifications
You must be signed in to change notification settings - Fork 7
/
criticalcss.php
150 lines (127 loc) · 4.61 KB
/
criticalcss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
/**
* Some of the following configuration options are the same as the ones you'll
* find in the Critical npm package.
*
* @see https://github.com/addyosmani/critical For more info.
*/
return [
/*
|--------------------------------------------------------------------------
| Routes
|--------------------------------------------------------------------------
|
| Routes (URIs) to generate critical-path CSS for.
| If 'null' is specified, all 'GET' routes will be used automatically. Use
| this option with caution.
|
| It is recommended that you specifically define the routes in an array.
|
| For 'static' routes with no parameters, simply add the route URI
| verbatim.
|
| However, for routes containing parameters, add an item with both a key
| and a value. The _key_ is an alias which is what you'll reference in
| Blade. The _value_ is the URI to request HTML from (the route with the
| parameters filled out.) Make sure the request won't 404.
|
*/
'routes' => [
// 'static/route', // In Blade: `@criticalCss('static/route')`
// 'users/profile' => 'users/1', // In Blade: `@criticalCss('users/profile')`
],
/*
|--------------------------------------------------------------------------
| CSS file(s)
|--------------------------------------------------------------------------
|
| CSS files to extract from. (The application's main CSS file(s).)
|
| The file is relative to the public path, i.e., `public_path($css)`.
|
*/
'css' => ['css/app.css', 'css/app2.css'],
/*
|--------------------------------------------------------------------------
| Viewport
|--------------------------------------------------------------------------
|
| Width and height of the target viewport.
|
*/
'width' => 1300,
'height' => 900,
/*
|--------------------------------------------------------------------------
| Ignore Rules
|--------------------------------------------------------------------------
|
| CSS rules to ignore. See filter-css for usage examples. You will also
| find some commented-out examples below.
| @see https://github.com/bezoerb/filter-css
|
*/
'ignore' => [
// Removes @font-face blocks
// '@font-face',
// Removes CSS selector
// '.selector',
// JS Regex, matches url(..) rules
// '/url(/',
],
/*
|--------------------------------------------------------------------------
| Storage Path
|--------------------------------------------------------------------------
|
| The directory which the generated critical-path CSS is stored.
|
*/
'storage' => 'critical-css',
/*
|--------------------------------------------------------------------------
| Pretend Mode
|--------------------------------------------------------------------------
|
| When this option is enabled, no critical-path will be inlined. This
| is very useful during development, as you don't want the inlined styles
| interfering after you've updated your main stylesheets.
|
| Remember to run `php artisan view:clear` after re-disabling this.
|
*/
'pretend' => env('CRITICALCSS_PRETEND', false),
/*
|--------------------------------------------------------------------------
| Blade Directive
|--------------------------------------------------------------------------
|
| Enable this to get access to the `@criticalCss($uri)` Blade directive.
| This is the recommended behavior for Laravel 5.1 and newer.
| If your app is running on Laravel 5.0, this must be disabled.
|
*/
'blade_directive' => true,
/*
|--------------------------------------------------------------------------
| Critical Path
|--------------------------------------------------------------------------
|
| Path to the Critical executable. If you have installed Critical in the
| project only, the default should be used. However, if Critical is
| installed globally, you may simply use 'critical'.
|
*/
'critical_bin' => base_path('node_modules/.bin/critical'),
/*
|--------------------------------------------------------------------------
| Timeout
|--------------------------------------------------------------------------
|
| Sets a maximum timeout, in milliseconds, for the CSS generation of a route.
| This parameter is passed to the Critical executable.
| Default value is 30000.
|
*/
'timeout' => 30000,
];