1 | <?php |
||
2 | /** |
||
3 | * Vite plugin for Craft CMS |
||
4 | * |
||
5 | * Allows the use of the Vite.js next generation frontend tooling with Craft CMS |
||
6 | * |
||
7 | * @link https://nystudio107.com |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | * @copyright Copyright (c) 2021 nystudio107 |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | namespace nystudio107\vite\models; |
||
12 | |||
13 | use craft\base\Model; |
||
14 | |||
15 | /** |
||
0 ignored issues
–
show
|
|||
16 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
17 | * @package Vite |
||
0 ignored issues
–
show
|
|||
18 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
19 | */ |
||
0 ignored issues
–
show
|
|||
20 | class Settings extends Model |
||
21 | { |
||
22 | // Public Properties |
||
23 | // ========================================================================= |
||
24 | |||
25 | /** |
||
0 ignored issues
–
show
|
|||
26 | * @var bool Should the dev server be used for? |
||
27 | */ |
||
28 | public bool $useDevServer = false; |
||
29 | |||
30 | /** |
||
0 ignored issues
–
show
|
|||
31 | * @var string File system path (or URL) to the Vite-built manifest.json |
||
32 | */ |
||
33 | public string $manifestPath = ''; |
||
34 | |||
35 | /** |
||
0 ignored issues
–
show
|
|||
36 | * @var string The public URL to the dev server (what appears in `<script src="">` tags |
||
37 | */ |
||
38 | public string $devServerPublic = ''; |
||
39 | |||
40 | /** |
||
0 ignored issues
–
show
|
|||
41 | * @var string The public URL to use when not using the dev server |
||
42 | */ |
||
43 | public string $serverPublic = ''; |
||
44 | |||
45 | /** |
||
0 ignored issues
–
show
|
|||
46 | * @var string|array The JavaScript entry from the manifest.json to inject on Twig error pages |
||
47 | * This can be a string or an array of strings |
||
48 | */ |
||
49 | public string|array $errorEntry = ''; |
||
50 | |||
51 | /** |
||
0 ignored issues
–
show
|
|||
52 | * @var string String to be appended to the cache key |
||
53 | */ |
||
54 | public string $cacheKeySuffix = ''; |
||
55 | |||
56 | /** |
||
0 ignored issues
–
show
|
|||
57 | * @var string The internal URL to the dev server, when accessed from the environment in which PHP is executing |
||
58 | * This can be the same as `$devServerPublic`, but may be different in containerized or VM setups. |
||
59 | * ONLY used if $checkDevServer = true |
||
60 | */ |
||
61 | public string $devServerInternal = ''; |
||
62 | |||
63 | /** |
||
0 ignored issues
–
show
|
|||
64 | * @var bool Should we check for the presence of the dev server by pinging $devServerInternal to make sure it's running? |
||
65 | */ |
||
66 | public bool $checkDevServer = false; |
||
67 | |||
68 | /** |
||
0 ignored issues
–
show
|
|||
69 | * @var bool Whether the react-refresh-shim should be included |
||
70 | */ |
||
71 | public bool $includeReactRefreshShim = false; |
||
72 | |||
73 | /** |
||
0 ignored issues
–
show
|
|||
74 | * @var bool Whether the modulepreload-polyfill shim should be included |
||
75 | */ |
||
76 | public bool $includeModulePreloadShim = true; |
||
77 | |||
78 | /** |
||
0 ignored issues
–
show
|
|||
79 | * @var string File system path (or URL) to where the Critical CSS files are stored |
||
80 | */ |
||
81 | public string $criticalPath = ''; |
||
82 | |||
83 | /** |
||
0 ignored issues
–
show
|
|||
84 | * @var string the suffix added to the name of the currently rendering template for the critical css file name |
||
85 | */ |
||
86 | public string $criticalSuffix = '_critical.min.css'; |
||
87 | |||
88 | // Public Methods |
||
89 | // ========================================================================= |
||
90 | |||
91 | /** |
||
0 ignored issues
–
show
|
|||
92 | * @inheritdoc |
||
93 | */ |
||
0 ignored issues
–
show
|
|||
94 | public function rules(): array |
||
95 | { |
||
96 | return [ |
||
97 | [ |
||
98 | [ |
||
99 | 'useDevServer', |
||
100 | 'checkDevServer', |
||
101 | 'includeReactRefreshShim', |
||
102 | 'includeModulePreloadShim', |
||
103 | ], |
||
104 | 'boolean', |
||
105 | ], |
||
106 | [ |
||
107 | [ |
||
108 | 'manifestPath', |
||
109 | 'devServerPublic', |
||
110 | 'serverPublic', |
||
111 | 'cacheKeySuffix', |
||
112 | 'devServerInternal', |
||
113 | ], |
||
114 | 'string', |
||
115 | ], |
||
116 | [ |
||
117 | [ |
||
118 | 'errorEntry', |
||
119 | ], |
||
120 | 'string', |
||
121 | ], |
||
122 | ]; |
||
123 | } |
||
124 | } |
||
125 |