@@ -30,7 +30,7 @@ pip install plonecli --user
30
30
Create an add-on package with ` plonecli ` .
31
31
32
32
``` shell
33
- plonecli add project.addon
33
+ plonecli create addon project.addon
34
34
```
35
35
36
36
This will create a package ` project.addon ` , which you can install in your Plone site.
@@ -52,6 +52,82 @@ You can check the full list of available features using the `-l` parameter:
52
52
plonecli -l
53
53
```
54
54
55
+ ## Create a custom pattern
56
+
57
+ To create a custom pattern in your addon use the ` mockup_pattern ` bobtemplate:
58
+
59
+ ``` shell
60
+ cd project.addon
61
+ plonecli add mockup_pattern
62
+ ```
63
+
64
+ Now enter your pattern name without * pat-* prefix:
65
+
66
+ ``` shell
67
+ --> Pattern name (without “pat-” prefix) [my-pattern]: testpattern
68
+ ```
69
+
70
+ This creates the necessary JS resources and webpack configuration for you:
71
+
72
+ ``` text
73
+ ...
74
+ ├── resources
75
+ | ├── pat-testpattern
76
+ | | ├── documentation.md
77
+ | | ├── testpattern.js
78
+ | | ├── testpattern.scss
79
+ | | ├── testpattern.test.js
80
+ │ ├── bundle.js
81
+ │ ├── index.html
82
+ │ ├── index.js
83
+ ├── package.json
84
+ ├── webpack.config.js
85
+ ...
86
+ ```
87
+
88
+ All your pattern JS code goes into ` resources/pat-testpattern/testpattern.js ` .
89
+ SCSS files can be imported too since webpack provides the ` sass-loader ` module.
90
+
91
+ Next step is to install the npm packages (yarn recommended):
92
+
93
+ ``` shell
94
+ yarn install
95
+ ```
96
+
97
+ When you have finished your JS code you have to build the bundle with:
98
+
99
+ ``` shell
100
+ yarn build
101
+ ```
102
+
103
+ This creates the webpack chunks and the JS bundle files in your addon package:
104
+
105
+ ``` text
106
+ ...
107
+ ├── src
108
+ | ├── project
109
+ | | ├── addon
110
+ | | | ├── browser
111
+ | | | | ├── static
112
+ | | | | | ├── bundles
113
+ | | | | | | ├── chunks
114
+ | | | | | | ├── addon-remote.min.js
115
+ | | | | | | ├── addon-remote.min.js.map
116
+ | | | | | | ├── addon.min.js
117
+ | | | | | | ├── addon.min.js.map
118
+ ```
119
+
120
+ Note that ` plonecli ` also creates a XML file in ` src/project/addon/profiles/default/registry/bundles.xml `
121
+ which registers the ` addon-remote.min.js ` in the resources registry.
122
+
123
+ ``` {important}
124
+ You have to re-import your profile with an upgrade step if you have installed
125
+ your addon in Plone before adding the pattern.
126
+ ```
127
+
128
+ You can test your pattern now with the browser view ` @@addon-pattern-demo ` (see /src/project/addon/browser/pattern-demo.pt)
129
+ or implement it in your own templates by adding the CSS class ` pat-testpattern ` to a tag.
130
+
55
131
56
132
## References
57
133
0 commit comments