1 | <?php |
||
2 | /** |
||
3 | * Twigpack plugin for Craft CMS 3.x |
||
4 | * |
||
5 | * Twigpack is the conduit between Twig and webpack, with manifest.json & |
||
6 | * webpack-dev-server HMR support |
||
7 | * |
||
8 | * @link https://nystudio107.com/ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
9 | * @copyright Copyright (c) 2018 nystudio107 |
||
0 ignored issues
–
show
|
|||
10 | */ |
||
0 ignored issues
–
show
|
|||
11 | |||
12 | namespace nystudio107\twigpack\models; |
||
13 | |||
14 | use craft\base\Model; |
||
15 | |||
16 | /** |
||
0 ignored issues
–
show
|
|||
17 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
18 | * @package Twigpack |
||
0 ignored issues
–
show
|
|||
19 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
20 | */ |
||
0 ignored issues
–
show
|
|||
21 | class Settings extends Model |
||
22 | { |
||
23 | // Public Properties |
||
24 | // ========================================================================= |
||
25 | |||
26 | /** |
||
0 ignored issues
–
show
|
|||
27 | * @var bool If `devMode` is on, use webpack-dev-server to all for HMR (hot |
||
28 | * module reloading) |
||
29 | */ |
||
30 | public bool $useDevServer = true; |
||
31 | |||
32 | /** |
||
0 ignored issues
–
show
|
|||
33 | * @var bool If true, enforces Absolute Urls, if false, allows relative |
||
34 | */ |
||
35 | public bool $useAbsoluteUrl = true; |
||
36 | |||
37 | /** |
||
0 ignored issues
–
show
|
|||
38 | * @var array|string The JavaScript entry from the manifest.json to inject on |
||
39 | * Twig error pages |
||
40 | */ |
||
41 | public array|string $errorEntry = ''; |
||
42 | |||
43 | /** |
||
0 ignored issues
–
show
|
|||
44 | * @var string String to be appended to the cache key |
||
45 | */ |
||
46 | public string $cacheKeySuffix = ''; |
||
47 | |||
48 | /** |
||
0 ignored issues
–
show
|
|||
49 | * @var array Manifest file names |
||
50 | */ |
||
51 | public array $manifest = [ |
||
52 | 'legacy' => 'manifest-legacy.json', |
||
53 | 'modern' => 'manifest.json', |
||
54 | ]; |
||
55 | |||
56 | /** |
||
0 ignored issues
–
show
|
|||
57 | * @var array Public server config |
||
58 | */ |
||
59 | public array $server = [ |
||
60 | 'manifestPath' => '/', |
||
61 | 'publicPath' => '/', |
||
62 | ]; |
||
63 | |||
64 | /** |
||
0 ignored issues
–
show
|
|||
65 | * @var array webpack-dev-server config |
||
66 | */ |
||
67 | public array $devServer = [ |
||
68 | 'manifestPath' => 'http://localhost:8080/', |
||
69 | 'publicPath' => 'http://localhost:8080/', |
||
70 | ]; |
||
71 | |||
72 | /** |
||
0 ignored issues
–
show
|
|||
73 | * @var string defines which bundle will be used from the webpack dev server. |
||
74 | * Can be 'modern', 'legacy' or 'combined'. Defaults to 'modern'. |
||
75 | */ |
||
76 | public string $devServerBuildType = 'modern'; |
||
77 | |||
78 | /** |
||
0 ignored issues
–
show
|
|||
79 | * @var string Whether to include a Content Security Policy "nonce" for inline |
||
80 | * CSS or JavaScript. Valid values are 'header' or 'tag' for how the CSP |
||
81 | * should be included. c.f.: |
||
82 | * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script |
||
83 | */ |
||
84 | public string $cspNonce = ''; |
||
85 | |||
86 | /** |
||
0 ignored issues
–
show
|
|||
87 | * @var array Local files config |
||
88 | */ |
||
89 | public array $localFiles = [ |
||
90 | 'basePath' => '@webroot/', |
||
91 | 'criticalPrefix' => 'dist/criticalcss/', |
||
92 | 'criticalSuffix' => '_critical.min.css', |
||
93 | ]; |
||
94 | |||
95 | // Public Methods |
||
96 | // ========================================================================= |
||
97 | |||
98 | /** |
||
0 ignored issues
–
show
|
|||
99 | * @inheritdoc |
||
100 | */ |
||
0 ignored issues
–
show
|
|||
101 | public function rules(): array |
||
102 | { |
||
103 | return [ |
||
104 | ['useDevServer', 'boolean'], |
||
105 | ['useDevServer', 'default', 'value' => true], |
||
106 | ['errorEntry', 'string'], |
||
107 | ['devServerBuildType', 'string'], |
||
108 | ['cspNonce', 'string'], |
||
109 | [ |
||
110 | [ |
||
111 | 'manifest', |
||
112 | 'server', |
||
113 | 'devServer', |
||
114 | 'localFiles', |
||
115 | ], |
||
116 | 'each', |
||
117 | 'rule' => ['string'], |
||
118 | ], |
||
119 | ]; |
||
120 | } |
||
121 | } |
||
122 |