You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The plugin comes with some default configuration. You may need to change it depending on your setup. Or you might not
94
95
need any config at all.
95
96
96
-
You can override some of these config settings through the `$options` of the helper methods. Or you can pass
97
-
your own instance of `ViteHelperConfig` to a helper method as a second parameter.
97
+
The default configuration is:
98
98
99
99
```php
100
100
'ViteHelper' => [
101
-
'build' => [
102
-
'outDirectory' => false, // output directory of build assets. string (e.g. 'dist') or false.
103
-
'manifest' => WWW_ROOT . 'manifest.json', // absolute path to manifest
104
-
],
101
+
'environment' => \ViteHelper\Enum\Environment::PRODUCTION, // available options PRODUCTION, DEVELOPMENT, FROM_DETECTOR
105
102
'development' => [
106
-
'scriptEntries' => ['someFolder/myScriptEntry.ts'], // relative to project root
107
-
'styleEntries' => ['someFolder/myStyleEntry.scss'], // relative to project root. Unnecessary when using css-in-js.
108
-
'hostNeedles' => ['.test', '.local'], // to check if the app is running locally
109
103
'url' => 'http://localhost:3000', // url of the vite dev server
110
104
],
111
-
'forceProductionMode' => false, // or true to always serve build assets
112
-
'plugin' => false, // or string 'MyPlugin' to serve plugin build assets
113
-
'productionHint' => 'vprod', // can be a true-ish cookie or url-param to serve build assets without changing the forceProductionMode config
114
-
'viewBlocks' => [
115
-
'css' => 'css', // name of the css view block
116
-
'script' => 'script', // name of the script view block
105
+
'builds' => [
106
+
[
107
+
'plugin' => null, // the plugin name or null if it doesn't exist. Default: null
108
+
'outputDirectory' => 'build', // the output directory relative to `webroot`. Default: 'build'
109
+
'manifest' => 'build' . DS . '.vite' . DS . 'manifest.json', // the relative path to the manifest file. Default: 'build' . DS . '.vite' . DS . 'manifest.json'
110
+
'environment' => \ViteHelper\Enum\Environment::PRODUCTION, // the forced environment, all files what 'falls' in this manifest file will be rendered this way. Default: the globally set environment
111
+
],
117
112
],
118
113
],
119
114
```
120
115
121
-
You can override the defaults in your `app.php`, `app_local.php`, or `app_vite.php`.
116
+
You can override the defaults in your `app.php`, `app_local.php`, or `app_vite.php`, also you can override in
117
+
`AppView.php` when you are loading the helper.
122
118
123
-
See the plugin's [app_vite.php](https://github.com/brandcom/cakephp-vite/blob/master/config/app_vite.php) for reference.
119
+
```php
120
+
$this->loadHelper('ViteHelper.ViteScripts', [
121
+
// ...your config goes here
122
+
]);
123
+
```
124
124
125
-
Example:
125
+
Since every build option has a default value:
126
126
127
127
```php
128
-
return [
129
-
'ViteHelper' => [
130
-
'forceProductionMode' => 1,
131
-
'development' => [
132
-
'hostNeedles' => ['.dev'], // if you don't use one of the defaults
133
-
'url' => 'https://192.168.0.88:3000',
134
-
],
128
+
'ViteHelper' => [
129
+
'environment' => \ViteHelper\Enum\Environment::DEVELOPMENT, // available options PRODUCTION, DEVELOPMENT, FROM_DETECTOR
130
+
'development' => [
131
+
'url' => 'http://localhost:3000', // url of the vite dev server
0 commit comments