Skip to content

Commit eb859f9

Browse files
authored
Improve organization
1 parent 82f3e45 commit eb859f9

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

console/asset-compilation-mix.md

+62-62
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,7 @@
11
# Asset Compilation - Mix
22

3-
## Registration
4-
53
By default, any plugin or theme containing a `winter.mix.js` file at its root will be automatically registered. Registered items can be viewed with the `mix:list` command.
64

7-
The following sections document additional ways to configure a Mix package, these are only required if you need additional customization.
8-
9-
### Registering plugins
10-
11-
To register frontend assets to be compiled through Mix in your plugin, simply return an array with the package names as the keys and the package paths relative to the plugin's directory as the values to register from your [`Plugin.php`](../plugin/registration) registration file's `registerMixPackages()` method. See below example.
12-
13-
```php
14-
public function registerMixPackages(): array
15-
{
16-
return [
17-
'custom-package-name' => 'assets/js/build.mix.js',
18-
];
19-
}
20-
```
21-
22-
### Registering themes
23-
24-
Registration of asset compilation of themes is even easier, and can be done by adding a `mix` definition to your [theme information file](../themes/development#theme-information-file) (`theme.yaml`).
25-
26-
```yaml
27-
name: "Winter CMS Demo"
28-
description: "Demonstrates the basic concepts of the frontend theming."
29-
author: "Winter CMS"
30-
homepage: "https://wintercms.com"
31-
code: "demo"
32-
33-
mix:
34-
<name of package>: winter.mix.js
35-
```
36-
37-
The `mix` definition takes any number of registered packages as a YAML object, with the key being the name of the package as a kebab-case string and the location of your `winter.mix.js` file relative to the theme's root directory.
38-
39-
For example, if you want to register two packages called `demo-theme-style` and `demo-theme-shop` located in the assets folder, you would use the following definition:
40-
41-
```yaml
42-
name: "Winter CMS Demo"
43-
description: "Demonstrates the basic concepts of the frontend theming."
44-
author: "Winter CMS"
45-
homepage: "https://wintercms.com"
46-
code: "demo"
47-
48-
mix:
49-
demo-theme-style: assets/style/winter.mix.js
50-
demo-theme-shop: assets/shop/winter.mix.js
51-
```
52-
53-
### Registering custom
54-
55-
You can configure a custom mix package that sits outside of plugins and themes.
56-
57-
```php
58-
use System\Classes\Asset\PackageManager;
59-
60-
PackageManager::instance()->registerPackage(
61-
name: 'my-custom-package',
62-
path: '/path/to/winter.mix.js',
63-
type: 'mix'
64-
);
65-
```
66-
675
<div id="automatic-configuration"></div>
686

697
## Automatic Mix configuration
@@ -170,3 +108,65 @@ php artisan mix:watch <package> [-f|--production] [-- <extra build options>]
170108
The `mix:watch` command is similar to the `mix:compile` command, except that it remains active and watches for any changes made to files that would be affected by your compilation. When any changes are made, a compile is automatically executed. This is useful for development in allowing you to quickly make changes and review them in your browser.
171109

172110
With this command, only one package can be provided and watched at any one time.
111+
112+
## Registration
113+
114+
The following sections document additional ways to configure a Mix package, these are only required if you need additional customization.
115+
116+
### Registering plugins
117+
118+
To register frontend assets to be compiled through Mix in your plugin, simply return an array with the package names as the keys and the package paths relative to the plugin's directory as the values to register from your [`Plugin.php`](../plugin/registration) registration file's `registerMixPackages()` method. See below example.
119+
120+
```php
121+
public function registerMixPackages(): array
122+
{
123+
return [
124+
'custom-package-name' => 'assets/js/build.mix.js',
125+
];
126+
}
127+
```
128+
129+
### Registering themes
130+
131+
Registration of asset compilation of themes is even easier, and can be done by adding a `mix` definition to your [theme information file](../themes/development#theme-information-file) (`theme.yaml`).
132+
133+
```yaml
134+
name: "Winter CMS Demo"
135+
description: "Demonstrates the basic concepts of the frontend theming."
136+
author: "Winter CMS"
137+
homepage: "https://wintercms.com"
138+
code: "demo"
139+
140+
mix:
141+
<name of package>: winter.mix.js
142+
```
143+
144+
The `mix` definition takes any number of registered packages as a YAML object, with the key being the name of the package as a kebab-case string and the location of your `winter.mix.js` file relative to the theme's root directory.
145+
146+
For example, if you want to register two packages called `demo-theme-style` and `demo-theme-shop` located in the assets folder, you would use the following definition:
147+
148+
```yaml
149+
name: "Winter CMS Demo"
150+
description: "Demonstrates the basic concepts of the frontend theming."
151+
author: "Winter CMS"
152+
homepage: "https://wintercms.com"
153+
code: "demo"
154+
155+
mix:
156+
demo-theme-style: assets/style/winter.mix.js
157+
demo-theme-shop: assets/shop/winter.mix.js
158+
```
159+
160+
### Registering custom
161+
162+
You can configure a custom mix package that sits outside of plugins and themes.
163+
164+
```php
165+
use System\Classes\Asset\PackageManager;
166+
167+
PackageManager::instance()->registerPackage(
168+
name: 'my-custom-package',
169+
path: '/path/to/winter.mix.js',
170+
type: 'mix'
171+
);
172+
```

0 commit comments

Comments
 (0)